1
2cd /data/tests/libc-test/src
3rm /data/tests/libc-test/REPORT
4rm /data/tests/libc-test/FileList.txt
5rm /data/tests/libc-test/SkipList.txt
6touch /data/tests/libc-test/REPORT
7touch /data/tests/libc-test/FileList.txt
8touch /data/tests/libc-test/SkipList.txt
9param set debug.hitrace.tags.enableflags 1
10
11ARCH=arm
12ABILIST=$(param get const.product.cpu.abilist)
13if [ $ABILIST == "arm64-v8a" ]; then
14    ARCH=aarch64
15fi
16
17function FileSuffix() {
18    local filename="$1"
19    if [ -n "$filename" ]; then
20        echo "${filename##*.}"
21    fi
22}
23
24#Test cases that need to be shielded
25ShieldedList=("trace_stresstest" "syslog" "vsyslog" "runtest"
26#Failed when running by shell, need to be run manually
27"tgkill_ext" "stat" "isatty" "ttyname" "a_stack_chk_fail"
28"ldso_randomization_manual" "ldso_randomization_test"
29"tcgetattr" "tcgetpgrp" "tcgetsid" "tcsendbreak" "tcsetattr" "tcsetpgrp"
30#These need run with special condiction
31"ipc_msg" "ipc_sem" "ipc_shm" "sem_close-unmap" "sem_open" "pthread_atfork-errno-clobber"
32"flockfile-list" "dlns_set_fun_test" "dlns_inherit_test" "dlns_separated_test"
33#Some math test cases need to skip.
34"acoshl" "asinhl" "erfcl" "fenv" "fma" "fmaf" "fmal" "lgammal" "nearbyint" "nearbyintf"
35"nearbyintl" "rint" "rintf" "rintl" "sqrt" "sqrtf" "sqrtl" "tgammal"
36#TODO-arm32
37"malloc-brk-fail" "pthread_cancel" "res_send"
38)
39
40#TODO-aarch64
41if [ $ARCH == "aarch64" ]; then
42  ShieldedList+=("faccessat" "signal" "unittest_hilog_vsnprint" "yn")
43fi
44
45for skiped in ${ShieldedList[*]};do
46    echo $skiped >> /data/tests/libc-test/SkipList.txt
47done
48
49function ShieldedCases() {
50	for filename in ${ShieldedList[*]}
51	do
52		if [ "$1" = "$filename" ];
53		then
54			echo "ShieldedCases"
55		fi
56	done
57}
58
59gwpasanTestList=(
60    "gwp_asan_buffer_overflow_test"
61    "gwp_asan_buffer_underflow_test"
62    "gwp_asan_double_free_test"
63    "gwp_asan_invalid_free_left_test"
64    "gwp_asan_invalid_free_right_test"
65    "gwp_asan_use_after_free_test"
66    "gwp_asan_unwind_test"
67    "gwp_asan_smoke_test"
68    "gwp_asan_random_sample_test"
69)
70
71function IsGwpasanTest() {
72	for filename in ${gwpasanTestList[*]}
73	do
74		if [ "$1" = "$filename" ];
75		then
76			echo "yes"
77		fi
78	done
79}
80
81for file in `ls *`
82do
83	if [ "$(FileSuffix ${file})" = "so" ] \
84	|| [ "$(ShieldedCases ${file})" = "ShieldedCases" ] \
85	|| [ "$(IsGwpasanTest ${file})" = "yes" ] \
86	|| [ -d $file ]
87	then
88		continue
89	elif [ -x $file ] && [ -s $file ]
90	then
91		echo $file >> /data/tests/libc-test/FileList.txt
92		./runtest -w '' -t 30 $file >> /data/tests/libc-test/REPORT
93	fi
94done
95
96echo "--- gwp_asan test running --- " >> /data/tests/libc-test/REPORT
97# gwp_asan test need to be executed at last.
98for file in `ls *`
99do
100	if [ "$(IsGwpasanTest ${file})" = "yes" ]
101	then
102		echo $file >> /data/tests/libc-test/FileList.txt
103
104		param set gwp_asan.log.path file
105		param set gwp_asan.enable.app.${file} true
106		if [ "${file}" != "gwp_asan_random_sample_test" ]
107		then 
108			param set gwp_asan.sample.all true
109		fi
110
111		echo "*** ${file} running ***" >> /data/tests/libc-test/REPORT
112		./${file} >> /data/tests/libc-test/REPORT
113		echo "*** ${file} done *** " >> /data/tests/libc-test/REPORT
114		param set gwp_asan.log.path default
115		param set gwp_asan.enable.app.${file} false
116		if [ "${file}" != "gwp_asan_random_sample_test" ]
117		then 
118			param set gwp_asan.sample.all false
119		fi
120	fi
121done
122echo "--- gwp_asan test done ---" >> /data/tests/libc-test/REPORT