diff options
author | HyungKyu Song <hk76.song@samsung.com> | 2013-02-16 00:16:10 +0900 |
---|---|---|
committer | HyungKyu Song <hk76.song@samsung.com> | 2013-02-16 00:16:10 +0900 |
commit | b99cf06f232ee59b688419debf2e588b9a459f5c (patch) | |
tree | ddb58e933c9da7c6e487b9df90589eeab0ee0957 /TC | |
parent | 563412390a7fdd82b9ebb1f1162a43cecaf56c5f (diff) | |
download | secure-storage-tizen_2.0.tar.gz secure-storage-tizen_2.0.tar.bz2 secure-storage-tizen_2.0.zip |
Diffstat (limited to 'TC')
-rwxr-xr-x | TC/build.sh | 20 | ||||
-rwxr-xr-x | TC/execute.sh | 19 | ||||
-rwxr-xr-x | TC/scenario1/Makefile | 27 | ||||
-rwxr-xr-x | TC/scenario1/tslist | 5 | ||||
-rwxr-xr-x | TC/scenario1/utc_SecurityFW_ssm_delete_file_func.c | 137 | ||||
-rwxr-xr-x | TC/scenario1/utc_SecurityFW_ssm_getinfo_func.c | 144 | ||||
-rwxr-xr-x | TC/scenario1/utc_SecurityFW_ssm_read_func.c | 187 | ||||
-rwxr-xr-x | TC/scenario1/utc_SecurityFW_ssm_write_buffer_func.c | 155 | ||||
-rwxr-xr-x | TC/scenario1/utc_SecurityFW_ssm_write_file_func.c | 147 | ||||
-rwxr-xr-x | TC/tet_code | 12 | ||||
-rwxr-xr-x | TC/tet_scen | 7 | ||||
-rwxr-xr-x | TC/tetbuild.cfg | 4 | ||||
-rwxr-xr-x | TC/tetclean.cfg | 3 | ||||
-rwxr-xr-x | TC/tetexec.cfg | 3 |
14 files changed, 870 insertions, 0 deletions
diff --git a/TC/build.sh b/TC/build.sh new file mode 100755 index 0000000..91656c9 --- /dev/null +++ b/TC/build.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +export TET_INSTALL_PATH=$HOME/work/TETware # local tetware path +export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target +export PATH=$TET_TARGET_PATH/bin:$PATH +export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH +export TET_ROOT=$TET_TARGET_PATH + +export TET_SUITE_ROOT=`pwd` +FILE_NAME_EXTENSION=`date +%s` + +RESULT_DIR=results +HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html +JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal + +mkdir -p $RESULT_DIR + +tcc -c -p ./ +tcc -b -j $JOURNAL_RESULT -p ./ +grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT diff --git a/TC/execute.sh b/TC/execute.sh new file mode 100755 index 0000000..e2c742e --- /dev/null +++ b/TC/execute.sh @@ -0,0 +1,19 @@ +#!/bin/sh +export TET_INSTALL_PATH=/mnt/nfs/TETware +export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target +export PATH=$TET_TARGET_PATH/bin:$PATH +export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH + +export TET_ROOT=$TET_TARGET_PATH + +export TET_SUITE_ROOT=`pwd` +FILE_NAME_EXTENSION=`date +%s` + +RESULT_DIR=results +HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html +JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal + +mkdir -p $RESULT_DIR + +tcc -e -j $JOURNAL_RESULT -p ./ +grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT diff --git a/TC/scenario1/Makefile b/TC/scenario1/Makefile new file mode 100755 index 0000000..454fc3e --- /dev/null +++ b/TC/scenario1/Makefile @@ -0,0 +1,27 @@ +CC ?= gcc + +TARGETS = \ + utc_SecurityFW_ssm_write_file_func \ + utc_SecurityFW_ssm_write_buffer_func \ + utc_SecurityFW_ssm_read_func \ + utc_SecurityFW_ssm_getinfo_func \ + utc_SecurityFW_ssm_delete_file_func + +PKGS = secure-storage + +LDFLAGS = `pkg-config --libs $(PKGS)` +LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o +LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s +LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s + +CFLAGS = -I. `pkg-config --cflags $(PKGS)` +CFLAGS += -I$(TET_ROOT)/inc/tet3 +CFLAGS += -Wall + +all: $(TARGETS) + +$(TARGETS): %: %.c + $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) + +clean: + rm -f $(TARGETS) *~ diff --git a/TC/scenario1/tslist b/TC/scenario1/tslist new file mode 100755 index 0000000..c04c3f0 --- /dev/null +++ b/TC/scenario1/tslist @@ -0,0 +1,5 @@ +/scenario1/utc_SecurityFW_ssm_write_file_func +/scenario1/utc_SecurityFW_ssm_write_buffer_func +/scenario1/utc_SecurityFW_ssm_read_func +/scenario1/utc_SecurityFW_ssm_getinfo_func +/scenario1/utc_SecurityFW_ssm_delete_file_func diff --git a/TC/scenario1/utc_SecurityFW_ssm_delete_file_func.c b/TC/scenario1/utc_SecurityFW_ssm_delete_file_func.c new file mode 100755 index 0000000..88f782c --- /dev/null +++ b/TC/scenario1/utc_SecurityFW_ssm_delete_file_func.c @@ -0,0 +1,137 @@ +/* + * secure storage + * + * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Contact: Kidong Kim <kd0228.kim@samsung.com> + * + * 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. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <ss_manager.h> +#include <tet_api.h> + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_SecurityFW_ssm_delete_file_func_01(void); +static void utc_SecurityFW_ssm_delete_file_func_02(void); + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +struct tet_testlist tet_testlist[] = { + { utc_SecurityFW_ssm_delete_file_func_01, POSITIVE_TC_IDX }, + { utc_SecurityFW_ssm_delete_file_func_02, NEGATIVE_TC_IDX }, + { NULL, 0 } +}; + +static void startup(void) +{ + printf("Make temporary directory - /opt/secure-storage/test/\n"); + system("mkdir -p /opt/secure-storage/test"); + printf("Make temporary file\n"); + system("touch /opt/secure-storage/test/input.txt"); + system("echo \"abcdefghij\" > /opt/secure-storage/test/input.txt"); + system("cp /opt/secure-storage/test/input.txt /opt/secure-storage/test/input2.txt"); +} + +static void cleanup(void) +{ + printf("Remove tamporary file and directory\n"); + system("rm -rf /opt/secure-storage/test"); +} + +/** + * @brief Positive test case of ssm_delete_file() + */ +static void utc_SecurityFW_ssm_delete_file_func_01(void) +{ + int tetResult = TET_FAIL; + /* variables for ssm_delete_file */ + int ret = -1; + char* filepath = "/opt/secure-storage/test/input.txt"; + ssm_flag flag = SSM_FLAG_DATA; + char* group_id = NULL; + + /* write file to secure-storage */ + ret = ssm_write_file(filepath, flag, group_id); + if(ret != 0) // if fail, + { + tetResult = TET_UNINITIATED; + goto error; + } + + /* delete file */ + ret = ssm_delete_file(filepath, flag, group_id); + if(ret == 0) + tetResult = TET_PASS; + else + tetResult = TET_FAIL; + +error: + printf("[%d] [%s]\n", tetResult, __FILE__); + tet_result(tetResult); +} + +/** + * @brief Negative test case of ssm_delete_file() + */ +static void utc_SecurityFW_ssm_delete_file_func_02(void) +{ + int tetResult = TET_FAIL; + /* variables for ssm_delete_file */ + int ret = -1; + char* filepath = "/opt/secure-storage/test/input2.txt"; + ssm_flag flag = SSM_FLAG_DATA; + char* group_id = NULL; + + printf("[%s] checkpoint1\n", __func__); + + /* write file to secure-storage */ + ret = ssm_write_file(filepath, flag, group_id); + printf("[%s] checkpoint2 [%d]\n", __func__, ret); + if(ret != 0) // if fail, + { + tetResult = TET_UNINITIATED; + goto error; + } + + /* delete file */ + ret = ssm_delete_file(NULL, flag, group_id); + printf("[%s] checkpoint3 [%d]\n", __func__, ret); + if(ret != 0) + tetResult = TET_PASS; + else + tetResult = TET_FAIL; + + /* delete encrypted file */ + ret = ssm_delete_file(filepath, flag, group_id); + printf("[%s] checkpoint4 [%d]\n", __func__, ret); + if(ret != 0) + tetResult = TET_UNINITIATED; + +error: + printf("[%d] [%s]\n", tetResult, __FILE__); + tet_result(tetResult); +} diff --git a/TC/scenario1/utc_SecurityFW_ssm_getinfo_func.c b/TC/scenario1/utc_SecurityFW_ssm_getinfo_func.c new file mode 100755 index 0000000..fb6064f --- /dev/null +++ b/TC/scenario1/utc_SecurityFW_ssm_getinfo_func.c @@ -0,0 +1,144 @@ +/* + * secure storage + * + * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Contact: Kidong Kim <kd0228.kim@samsung.com> + * + * 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. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <ss_manager.h> +#include <tet_api.h> + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_SecurityFW_ssm_getinfo_func_01(void); +static void utc_SecurityFW_ssm_getinfo_func_02(void); + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +struct tet_testlist tet_testlist[] = { + { utc_SecurityFW_ssm_getinfo_func_01, POSITIVE_TC_IDX }, + { utc_SecurityFW_ssm_getinfo_func_02, NEGATIVE_TC_IDX }, + { NULL, 0 } +}; + +static void startup(void) +{ + printf("Make temporary directory - /opt/secure-storage/test/\n"); + system("mkdir -p /opt/secure-storage/test"); + printf("Make temporary file\n"); + system("touch /opt/secure-storage/test/input.txt"); + system("echo \"abcdefghij\" > /opt/secure-storage/test/input.txt"); + system("cp /opt/secure-storage/test/input.txt /opt/secure-storage/test/input2.txt"); +} + +static void cleanup(void) +{ + printf("Remove tamporary file and directory\n"); + system("rm -rf /opt/secure-storage/test"); +} + +/** + * @brief Positive test case of ssm_getinfo() + */ +static void utc_SecurityFW_ssm_getinfo_func_01(void) +{ + int tetResult = TET_FAIL; + /* variables for ssm_write_file */ + int ret = -1; + char* filepath = "/opt/secure-storage/test/input.txt"; + ssm_flag flag = SSM_FLAG_DATA; + char* group_id = NULL; + ssm_file_info_t sfi; + + /* write file to secure-storage */ + ret = ssm_write_file(filepath, flag, group_id); + if(ret != 0) // if fail, + { + tetResult = TET_UNINITIATED; + goto error; + } + + /* get information */ + ret = ssm_getinfo(filepath, &sfi, flag, group_id); + if(ret == 0) // success + tetResult = TET_PASS; + else + tetResult = TET_FAIL; + + /* delete encrypted file */ + ret = ssm_delete_file(filepath, flag, group_id); + if(ret != 0) + tetResult = TET_UNINITIATED; + +error: + printf("[%d] [%s]\n", tetResult, __FILE__); + tet_result(tetResult); +} + +/** + * @brief Negative test case of ssm_getinfo() + */ +static void utc_SecurityFW_ssm_getinfo_func_02(void) +{ + int tetResult = TET_FAIL; + /* variables for ssm_write_file */ + int ret = -1; + char* filepath = "/opt/secure-storage/test/input2.txt"; + ssm_flag flag = SSM_FLAG_DATA; + char* group_id = NULL; + ssm_file_info_t sfi; + + printf("[%s] checkpoint1\n", __func__); + + /* write file to secure-storage */ + ret = ssm_write_file(filepath, flag, group_id); + printf("[%s] checkpoint2 [%d]\n", __func__, ret); + if(ret != 0) // if fail, + { + tetResult = TET_UNINITIATED; + goto error; + } + + /* get information */ + ret = ssm_getinfo(NULL, &sfi, flag, group_id); + printf("[%s] checkpoint3 [%d]\n", __func__, ret); + if(ret == 0) // success + tetResult = TET_FAIL; + else + tetResult = TET_PASS; + + /* delete encrypted file */ + ret = ssm_delete_file(filepath, flag, group_id); + printf("[%s] checkpoint4 [%d]\n", __func__, ret); + if(ret != 0) + tetResult = TET_UNINITIATED; + +error: + printf("[%d] [%s]\n", tetResult, __FILE__); + tet_result(tetResult); +} diff --git a/TC/scenario1/utc_SecurityFW_ssm_read_func.c b/TC/scenario1/utc_SecurityFW_ssm_read_func.c new file mode 100755 index 0000000..e976f06 --- /dev/null +++ b/TC/scenario1/utc_SecurityFW_ssm_read_func.c @@ -0,0 +1,187 @@ +/* + * secure storage + * + * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Contact: Kidong Kim <kd0228.kim@samsung.com> + * + * 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. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <ss_manager.h> +#include <tet_api.h> + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_SecurityFW_ssm_read_func_01(void); +static void utc_SecurityFW_ssm_read_func_02(void); + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +struct tet_testlist tet_testlist[] = { + { utc_SecurityFW_ssm_read_func_01, POSITIVE_TC_IDX }, + { utc_SecurityFW_ssm_read_func_02, NEGATIVE_TC_IDX }, + { NULL, 0 } +}; + +static void startup(void) +{ + printf("Make temporary directory - /opt/secure-storage/test/\n"); + system("mkdir -p /opt/secure-storage/test"); + printf("Make temporary file\n"); + system("touch /opt/secure-storage/test/input.txt"); + system("echo \"abcdefghij\" > /opt/secure-storage/test/input.txt"); + system("cp /opt/secure-storage/test/input.txt /opt/secure-storage/test/input2.txt"); +} + +static void cleanup(void) +{ + printf("Remove tamporary file and directory\n"); + system("rm -rf /opt/secure-storage/test"); +} + +/** + * @brief Positive test case of ssm_read() + */ +static void utc_SecurityFW_ssm_read_func_01(void) +{ + int tetResult = TET_FAIL; + /* variables for ssm_write_file */ + int ret = -1; + char* filepath = "/opt/secure-storage/test/input.txt"; + ssm_flag flag = SSM_FLAG_DATA; + char* group_id = NULL; + + /* variables for ssm_read */ + FILE* fp_original = NULL; + char buf[20]; + char* retbuf = NULL; + int readlen = 0; + ssm_file_info_t sfi; + + /* get original file content. after encrypting, original file will be deleted */ + memset(buf, 0x00, 20); + fp_original = fopen(filepath, "r"); + fgets(buf, 20, fp_original); + fclose(fp_original); + + /* write file to secure-storage */ + ret = ssm_write_file(filepath, flag, group_id); + if(ret != 0) // if fail, + { + tetResult = TET_UNINITIATED; + goto error; + } + + /* read and compare */ + ssm_getinfo(filepath, &sfi, flag, group_id); + retbuf = (char*)malloc(sizeof(char) * (sfi.originSize + 1)); + memset(retbuf, 0x00, (sfi.originSize + 1)); + ret = ssm_read(filepath, retbuf, sfi.originSize, &readlen, flag, group_id); + if(ret != 0) // if fail, + { + tetResult = TET_UNINITIATED; + goto free_error; + } + + if(tetResult != TET_UNINITIATED) + { + if(!memcmp(buf, retbuf, strlen(retbuf))) // if same + tetResult = TET_PASS; + else + tetResult = TET_FAIL; + } + + /* delete encrypted file */ + ret = ssm_delete_file(filepath, flag, group_id); + if(ret != 0) + tetResult = TET_UNINITIATED; + +free_error: + free(retbuf); +error: + printf("[%d] [%s]\n", tetResult, __FILE__); + tet_result(tetResult); +} + +/** + * @brief Negative test case of ssm_read() + */ +static void utc_SecurityFW_ssm_read_func_02(void) +{ + int tetResult = TET_FAIL; + /* variables for ssm_write_file */ + int ret = -1; + char* filepath = "/opt/secure-storage/test/input2.txt"; + ssm_flag flag = SSM_FLAG_DATA; + char* group_id = NULL; + + /* variables for ssm_read */ + FILE* fp_original = NULL; + char buf[20]; + char* retbuf = NULL; + int readlen = 0; + ssm_file_info_t sfi; + + /* get original file content. after encrypting, original file will be deleted */ + memset(buf, 0x00, 20); + fp_original = fopen(filepath, "r"); + fgets(buf, 20, fp_original); + fclose(fp_original); + + printf("[%s] checkpoint1\n", __func__); + + /* write file to secure-storage */ + ret = ssm_write_file(filepath, flag, group_id); + printf("[%s] checkpoint2 [%d]\n", __func__, ret); + if(ret != 0) // if fail, + { + tetResult = TET_UNINITIATED; + goto error; + } + + /* read and compare */ + ret = ssm_getinfo(filepath, &sfi, flag, group_id); + printf("[%s] checkpoint3 [%d]\n", __func__, ret); + retbuf = (char*)malloc(sizeof(char) * (sfi.originSize + 1)); + memset(retbuf, 0x00, (sfi.originSize + 1)); + ret = ssm_read(NULL, retbuf, sfi.originSize, &readlen, flag, group_id); + printf("[%s] checkpoint4 [%d]\n", __func__, ret); + if(ret != 0) // if fail, + tetResult = TET_PASS; + else + tetResult = TET_FAIL; + + /* delete encrypted file */ + ret = ssm_delete_file(filepath, flag, group_id); + printf("[%s] checkpoint5 [%d]\n", __func__, ret); + if(ret != 0) + tetResult = TET_UNINITIATED; + + free(retbuf); +error: + printf("[%d] [%s]\n", tetResult, __FILE__); + tet_result(tetResult); +} diff --git a/TC/scenario1/utc_SecurityFW_ssm_write_buffer_func.c b/TC/scenario1/utc_SecurityFW_ssm_write_buffer_func.c new file mode 100755 index 0000000..50faf2c --- /dev/null +++ b/TC/scenario1/utc_SecurityFW_ssm_write_buffer_func.c @@ -0,0 +1,155 @@ +/* + * secure storage + * + * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Contact: Kidong Kim <kd0228.kim@samsung.com> + * + * 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. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <ss_manager.h> +#include <tet_api.h> + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_SecurityFW_ssm_write_buffer_func_01(void); +static void utc_SecurityFW_ssm_write_buffer_func_02(void); + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +struct tet_testlist tet_testlist[] = { + { utc_SecurityFW_ssm_write_buffer_func_01, POSITIVE_TC_IDX }, + { utc_SecurityFW_ssm_write_buffer_func_02, NEGATIVE_TC_IDX }, + { NULL, 0 } +}; + +static void startup(void) +{ + printf("Make temporary directory - /opt/secure-storage/test/\n"); + system("mkdir -p /opt/secure-storage/test"); + printf("Make temporary file\n"); + system("touch /opt/secure-storage/test/input.txt"); + system("echo \"abcdefghij\" > /opt/secure-storage/test/input.txt"); +} + +static void cleanup(void) +{ + printf("Remove tamporary file and directory\n"); + system("rm -rf /opt/secure-storage/test"); +} + +/** + * @brief Positive test case of ssm_write_buffer() + */ +static void utc_SecurityFW_ssm_write_buffer_func_01(void) +{ + int tetResult = TET_FAIL; + /* variables for ssm_write_buffer */ + int ret = -1; + char oribuf[20]; + ssm_flag flag = SSM_FLAG_SECRET_OPERATION; + char* group_id = NULL; + char* filename = "write_buffer.txt"; + int buflen = 0; + + /* variables for ssm_read */ + char buf[20]; + char* retbuf = NULL; + int readlen = 0; + ssm_file_info_t sfi; + + /* set contents in buffers */ + memset(oribuf, 0x00, 20); + memset(buf, 0x00, 20); + strncpy(oribuf, "abcdefghij", 10); // original buffer + strncpy(buf, "abcdefghij", 10); // encrypting + + buflen = strlen(buf); + + /* write file to secure-storage */ + ret = ssm_write_buffer(buf, buflen, filename, flag, group_id); + if(ret != 0) // if fail, + { + tetResult = TET_UNINITIATED; + goto error; + } + + /* read and compare */ + ssm_getinfo(filename, &sfi, flag, group_id); + retbuf = (char*)malloc(sizeof(char) * (sfi.originSize + 1)); + memset(retbuf, 0x00, (sfi.originSize + 1)); + + ret = ssm_read(filename, retbuf, sfi.originSize, &readlen, flag, group_id); + if(ret != 0) // if fail, + { + tetResult = TET_UNINITIATED; + goto free_error; + } + + if(tetResult != TET_UNINITIATED) + { + if(!memcmp(oribuf, retbuf, strlen(retbuf))) // if same + tetResult = TET_PASS; + else + tetResult = TET_FAIL; + } + + /* delete encrypted file */ + ret = ssm_delete_file(filename, flag, group_id); + if(ret != 0) + tetResult = TET_UNINITIATED; + +free_error: + free(retbuf); +error: + printf("[%d] [%s]\n", tetResult, __FILE__); + tet_result(tetResult); +} + +/** + * @brief Negative test case of ssm_write_buffer() + */ +static void utc_SecurityFW_ssm_write_buffer_func_02(void) +{ + int tetResult = TET_FAIL; + /* variables for ssm_write_buffer */ + int ret = -1; + char* filename = "write_buffer.txt"; + ssm_flag flag = SSM_FLAG_SECRET_OPERATION; + char buf[20]; + int buflen = 0; + char* group_id = NULL; + + /* write file to secure-storage */ + ret = ssm_write_buffer(NULL, buflen, filename, flag, group_id); + if(ret != 0) // if fail, + tetResult = TET_PASS; + else + tetResult = TET_FAIL; + + printf("[%d] [%s]\n", tetResult, __FILE__); + tet_result(tetResult); +} diff --git a/TC/scenario1/utc_SecurityFW_ssm_write_file_func.c b/TC/scenario1/utc_SecurityFW_ssm_write_file_func.c new file mode 100755 index 0000000..a502992 --- /dev/null +++ b/TC/scenario1/utc_SecurityFW_ssm_write_file_func.c @@ -0,0 +1,147 @@ +/* + * secure storage + * + * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Contact: Kidong Kim <kd0228.kim@samsung.com> + * + * 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. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <ss_manager.h> +#include <tet_api.h> + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_SecurityFW_ssm_write_file_func_01(void); +static void utc_SecurityFW_ssm_write_file_func_02(void); + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +struct tet_testlist tet_testlist[] = { + { utc_SecurityFW_ssm_write_file_func_01, POSITIVE_TC_IDX }, + { utc_SecurityFW_ssm_write_file_func_02, NEGATIVE_TC_IDX }, + { NULL, 0 } +}; + +static void startup(void) +{ + printf("Make temporary directory - /opt/secure-storage/test/\n"); + system("mkdir -p /opt/secure-storage/test"); + printf("Make temporary file\n"); + system("touch /opt/secure-storage/test/input.txt"); + system("echo \"abcdefghij\" > /opt/secure-storage/test/input.txt"); +} + +static void cleanup(void) +{ + printf("Remove tamporary file and directory\n"); + system("rm -rf /opt/secure-storage/test"); +} + +/** + * @brief Positive test case of ssm_write_file() + */ +static void utc_SecurityFW_ssm_write_file_func_01(void) +{ + int tetResult = TET_FAIL; + /* variables for ssm_write_file */ + int ret = -1; + char* filepath = "/opt/secure-storage/test/input.txt"; + ssm_flag flag = SSM_FLAG_DATA; + char* group_id = NULL; + + /* variables for ssm_read */ + FILE* fp_original = NULL; + char buf[20]; + char* retbuf = NULL; + int readlen = 0; + ssm_file_info_t sfi; + + /* get original file content. after encrypting, original file will be deleted */ + memset(buf, 0x00, 20); + fp_original = fopen(filepath, "r"); + fgets(buf, 20, fp_original); + fclose(fp_original); + + /* write file to secure-storage */ + ret = ssm_write_file(filepath, flag, group_id); + if(ret != 0) { // if fail, + tetResult = TET_UNINITIATED; + goto error; + } + + /* read and compare */ + ssm_getinfo(filepath, &sfi, flag, group_id); + retbuf = (char*)malloc(sizeof(char) * (sfi.originSize + 1)); + memset(retbuf, 0x00, (sfi.originSize + 1)); + ret = ssm_read(filepath, retbuf, sfi.originSize, &readlen, flag, group_id); + if(ret != 0) { // if fail, + tetResult = TET_UNINITIATED; + goto free_error; + } + + if(tetResult != TET_UNINITIATED) + { + if(!memcmp(buf, retbuf, strlen(retbuf))) // if same + tetResult = TET_PASS; + else + tetResult = TET_FAIL; + } + + /* delete encrypted file */ + ret = ssm_delete_file(filepath, flag, group_id); + if(ret != 0) + tetResult = TET_UNINITIATED; + +free_error: + free(retbuf); +error: + printf("[%d] [%s]\n", tetResult, __FILE__); + tet_result(tetResult); +} + +/** + * @brief Negative test case of ssm_write_file() + */ +static void utc_SecurityFW_ssm_write_file_func_02(void) +{ + int tetResult = TET_FAIL; + /* variables for ssm_write_file */ + int ret = -1; + char* filepath = "/opt/secure-storage/test/input.txt"; + ssm_flag flag = SSM_FLAG_DATA; + char* group_id = NULL; + + /* write file to secure-storage */ + ret = ssm_write_file(NULL, flag, group_id); + if(ret != 0) // if fail, + tetResult = TET_PASS; + else + tetResult = TET_FAIL; + + printf("[%d] [%s]\n", tetResult, __FILE__); + tet_result(tetResult); +} diff --git a/TC/tet_code b/TC/tet_code new file mode 100755 index 0000000..a2cf6c1 --- /dev/null +++ b/TC/tet_code @@ -0,0 +1,12 @@ +# TET reserved codes +0 "PASS" +1 "FAIL" +2 "UNRESOLVED" +3 "NOTINUSE" +4 "UNSUPPORTED" +5 "UNTESTED" +6 "UNINITIATED" +7 "NORESULT" + +# Test suite additional codes +33 "INSPECT" diff --git a/TC/tet_scen b/TC/tet_scen new file mode 100755 index 0000000..c63a380 --- /dev/null +++ b/TC/tet_scen @@ -0,0 +1,7 @@ +all + ^TEST +##### Scenarios for TEST ##### + +# Test scenario +TEST + :include:/scenario1/tslist diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg new file mode 100755 index 0000000..1f80874 --- /dev/null +++ b/TC/tetbuild.cfg @@ -0,0 +1,4 @@ +TET_OUTPUT_CAPTURE=False +TET_BUILD_TOOL=make +TET_PASS_TC_NAME=True +TET_API_COMPLIANT=True diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg new file mode 100755 index 0000000..55ef6b5 --- /dev/null +++ b/TC/tetclean.cfg @@ -0,0 +1,3 @@ +TET_OUTPUT_CAPTURE=False +TET_CLEAN_TOOL=make clean +TET_API_COMPLIANT=True diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg new file mode 100755 index 0000000..eb4f0d3 --- /dev/null +++ b/TC/tetexec.cfg @@ -0,0 +1,3 @@ +TET_OUTPUT_CAPTURE=True +TET_API_COMPLIANT=True +TET_PASS_TC_NAME=True |