# common - common part for other scripts  
#
# Copyright (c) 2019-2023 Wind River Systems, Inc.
#      
# The right to copy, distribute, modify or otherwise make use
# of this software may be licensed only pursuant to the terms
# of an applicable Wind River license agreement.
#
#/bin/sh

####################################################
### Determine which tests need to compile        ###
####################################################
src_file_list=$(ls *.c testutil/*.c helpers/*.c)

build_black_list="
	bioprinttest.c
	uitest.c
	drbgtest.c
	drbg_cavs_test.c
	rdrand_sanitytest.c
	versions.c
	tls13secretstest.c
	shlibloadtest.c
	simpledynamic.c
	moduleloadtest.c
"

#Exclude test files with main function
build_black_list=$build_black_list" "$(grep -snrl "int main.*argc.*argv" *.c)

for src_file in ${src_file_list}
do
	is_black_file="FALSE"
	for black_file in ${build_black_list}
	do
		if [ "x$src_file" = "x$black_file" ]; then
			is_black_file="TRUE"
			break
		fi
	done

	if [ "x$is_black_file" = "xFALSE" ]; then
		build_file_list=${build_file_list}" "${src_file}" "
		(( build_file_count=build_file_count+1 ))
	fi

done
build_file_count=$(echo ${build_file_list} | wc -w)


runnable_file_list_legacy=" ecdhtest.c md4test.c md5test.c randtest.c rmdtest.c sha1test.c sha256test.c sha512test.c "
runnable_file_list=$(grep -snrl "int setup_tests(void)" ${build_file_list})" "${runnable_file_list_legacy}
runnable_file_count=$(echo ${runnable_file_list} | wc -w)


#echo "###build_file_list: "
#echo "$build_file_list"
#echo "###build_file_count: "
#echo "$build_file_count"
#echo "###runnable_file_list: "
#echo "$runnable_file_list"
#echo "###runnable_file_count: "
#echo "$runnable_file_count"


