From 065890aef4317aa6a56f58a4045bdafbae37861e Mon Sep 17 00:00:00 2001 From: Kyungwook Tak Date: Wed, 18 May 2016 23:50:29 +0900 Subject: [PATCH] Make header for common test resource definition Change-Id: I71f20bc2a78465e5e38b723b0d669545a989ba6a Signed-off-by: Kyungwook Tak --- test/internals/test-file-system.cpp | 12 ++++---- test/test-api-content-screening.cpp | 39 +----------------------- test/test-resource.h | 59 +++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 45 deletions(-) create mode 100644 test/test-resource.h diff --git a/test/internals/test-file-system.cpp b/test/internals/test-file-system.cpp index 2cdb95a..013540f 100644 --- a/test/internals/test-file-system.cpp +++ b/test/internals/test-file-system.cpp @@ -38,8 +38,8 @@ #include #include "test-common.h" +#include "test-resource.h" -#define TEST_APP_PKG TEST_DIR "/maliciousapp.tpk" #define TEST_DIR_VISIT TEST_DIR "/test_dir" #define TEST_WRITE_FILE TEST_DIR_VISIT "/testwritefile.txt" @@ -153,16 +153,14 @@ BOOST_AUTO_TEST_CASE(remove_app) { EXCEPTION_GUARD_START - std::string fpath = - "/opt/usr/apps/org.example.maliciousapp/shared/res/maliciousapp.png"; - + Test::uninstall_app(TEST_TPK_PKG_ID); // install the test app - BOOST_REQUIRE(Test::install_app(TEST_APP_PKG, "TPK")); + ASSERT_INSTALL_APP(TEST_TPK_PATH, TEST_TPK_TYPE); // remove the app - auto app = File::create(fpath); + auto app = File::create(TEST_TPK_MAL_FILE); CHECK_IS_NOT_NULL(app); - BOOST_REQUIRE_NO_THROW(app->remove()); + app->remove(); // check if the app still exists pkgmgrinfo_pkginfo_h handle; diff --git a/test/test-api-content-screening.cpp b/test/test-api-content-screening.cpp index 4d82bb5..a5ea72c 100644 --- a/test/test-api-content-screening.cpp +++ b/test/test-api-content-screening.cpp @@ -30,44 +30,7 @@ #include "test-common.h" #include "test-helper.h" - -#define TEST_FILE_NORMAL TEST_DIR "/test_normal_file" -#define TEST_FILE_HIGH TEST_DIR "/test_malware_file" -#define TEST_FILE_MEDIUM TEST_DIR "/test_risky_file" -#define TEST_FILE_LOW TEST_DIR "/test_generic_file" - -#define TEST_FILE_MEDIA "/opt/usr/media/test_malware_file" -#define TEST_FILE_TMP "/tmp/test_malware_file" -#define TEST_FILE_APP_ROOT "/opt/usr/apps" -#define TEST_FILE_NO_EXIST "/tmp/not_existing_file" - -#define TEST_WGT_PKG_ID "hFhcNcbE6K" -#define TEST_WGT_APP_ROOT TEST_FILE_APP_ROOT "/" TEST_WGT_PKG_ID -#define TEST_WGT_MAL_FILE TEST_WGT_APP_ROOT "/res/wgt/data/malicious.txt" -#define TEST_WGT_PATH TEST_DIR "/" TEST_TARGET "/MaliciousWgt.wgt" -#define TEST_WGT_TYPE "WGT" - -#define TEST_TPK_PKG_ID "org.example.malicioustpk" -#define TEST_TPK_APP_ROOT TEST_FILE_APP_ROOT "/" TEST_TPK_PKG_ID -#define TEST_TPK_MAL_FILE TEST_TPK_APP_ROOT "/shared/res/malicious.txt" -#define TEST_TPK_PATH TEST_DIR "/" TEST_TARGET "/MaliciousTpk.tpk" -#define TEST_TPK_TYPE "TPK" - -#define MALWARE_HIGH_NAME "test_malware" -#define MALWARE_HIGH_SEVERITY CSR_CS_SEVERITY_HIGH -#define MALWARE_HIGH_DETAILED_URL "http://high.malware.com" -#define MALWARE_HIGH_SIGNATURE "X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*" - -#define MALWARE_MEDIUM_NAME "test_risk" -#define MALWARE_MEDIUM_SEVERITY CSR_CS_SEVERITY_MEDIUM -#define MALWARE_MEDIUM_DETAILED_URL "http://medium.malware.com" -#define MALWARE_MEDIUM_SIGNATURE "RISKY_MALWARE" - -#define MALWARE_LOW_NAME "test_generic" -#define MALWARE_LOW_SEVERITY CSR_CS_SEVERITY_LOW -#define MALWARE_LOW_DETAILED_URL "http://low.malware.com" -#define MALWARE_LOW_SIGNATURE "GENERIC_MALWARE" - +#include "test-resource.h" BOOST_AUTO_TEST_SUITE(API_CONTENT_SCREENING) diff --git a/test/test-resource.h b/test/test-resource.h new file mode 100644 index 0000000..6133406 --- /dev/null +++ b/test/test-resource.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ +/* + * @file test-resource.h + * @author Kyungwook Tak (k.tak@samsung.com) + * @version 1.0 + * @brief Test resoure name and paths + */ +#pragma once + +#define TEST_FILE_NORMAL TEST_DIR "/test_normal_file" +#define TEST_FILE_HIGH TEST_DIR "/test_malware_file" +#define TEST_FILE_MEDIUM TEST_DIR "/test_risky_file" +#define TEST_FILE_LOW TEST_DIR "/test_generic_file" + +#define TEST_FILE_MEDIA "/opt/usr/media/test_malware_file" +#define TEST_FILE_TMP "/tmp/test_malware_file" +#define TEST_FILE_APP_ROOT "/opt/usr/apps" +#define TEST_FILE_NO_EXIST "/tmp/not_existing_file" + +#define TEST_WGT_PKG_ID "hFhcNcbE6K" +#define TEST_WGT_APP_ROOT TEST_FILE_APP_ROOT "/" TEST_WGT_PKG_ID +#define TEST_WGT_MAL_FILE TEST_WGT_APP_ROOT "/res/wgt/data/malicious.txt" +#define TEST_WGT_PATH TEST_DIR "/" TEST_TARGET "/MaliciousWgt.wgt" +#define TEST_WGT_TYPE "WGT" + +#define TEST_TPK_PKG_ID "org.example.malicioustpk" +#define TEST_TPK_APP_ROOT TEST_FILE_APP_ROOT "/" TEST_TPK_PKG_ID +#define TEST_TPK_MAL_FILE TEST_TPK_APP_ROOT "/shared/res/malicious.txt" +#define TEST_TPK_PATH TEST_DIR "/" TEST_TARGET "/MaliciousTpk.tpk" +#define TEST_TPK_TYPE "TPK" + +#define MALWARE_HIGH_NAME "test_malware" +#define MALWARE_HIGH_SEVERITY CSR_CS_SEVERITY_HIGH +#define MALWARE_HIGH_DETAILED_URL "http://high.malware.com" +#define MALWARE_HIGH_SIGNATURE "X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*" + +#define MALWARE_MEDIUM_NAME "test_risk" +#define MALWARE_MEDIUM_SEVERITY CSR_CS_SEVERITY_MEDIUM +#define MALWARE_MEDIUM_DETAILED_URL "http://medium.malware.com" +#define MALWARE_MEDIUM_SIGNATURE "RISKY_MALWARE" + +#define MALWARE_LOW_NAME "test_generic" +#define MALWARE_LOW_SEVERITY CSR_CS_SEVERITY_LOW +#define MALWARE_LOW_DETAILED_URL "http://low.malware.com" +#define MALWARE_LOW_SIGNATURE "GENERIC_MALWARE" -- 2.7.4