Skip to content

Commit

Permalink
test: add tasking tests
Browse files Browse the repository at this point in the history
Add unit tests to test the tasking tricore ctc/cctc compiler
support.
  • Loading branch information
louiscaron committed Oct 19, 2021
1 parent 5d2c1aa commit 9851d84
Show file tree
Hide file tree
Showing 4 changed files with 383 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ addtest(cleanup)
addtest(color_diagnostics)
addtest(config)
addtest(cpp1)
addtest(ctc)
addtest(cctc)
addtest(debug_prefix_map)
addtest(depend)
addtest(direct)
Expand Down
14 changes: 14 additions & 0 deletions test/run
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,8 @@ COMPILER_ARGS=$(echo $CC | awk '{$1 = ""; print}')
REAL_COMPILER_BIN=$(find_compiler $COMPILER_BIN)
REAL_COMPILER="$REAL_COMPILER_BIN$COMPILER_ARGS"
REAL_NVCC=$(find_compiler nvcc)
REAL_CTC=$(find_compiler ctc)
REAL_CCTC=$(find_compiler cctc)

if [ "$REAL_COMPILER_BIN" = "$COMPILER_BIN" ]; then
echo "Compiler: $CC"
Expand All @@ -596,6 +598,18 @@ if [ -n "$REAL_NVCC" ]; then
else
echo "CUDA compiler: not available"
fi

if [ -n "$REAL_CTC" ]; then
echo "Tasking compiler: $($REAL_CTC --version | tail -n 1) ($REAL_CTC)"
else
echo "Tasking compiler: not available"
fi

if [ -n "$REAL_CCTC" ]; then
echo "Tasking control program: $($REAL_CCTC --version | tail -n 1) ($REAL_CCTC)"
else
echo "Tasking control program: not available"
fi
echo

cd $TESTDIR || exit 1
Expand Down
131 changes: 131 additions & 0 deletions test/suites/cctc.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
cctc_PROBE() {
if [ -z "$REAL_CCTC" ]; then
echo "ctc is not available"
fi
}

cctc_SETUP() {
generate_code 1 test1.c
}

cctc_tests() {
# -------------------------------------------------------------------------
TEST "Base case"

# test compilation without ccache to get a reference file
$REAL_CCTC --core=tc1.6.2 --create=object -o reference_test1.o test1.c

# First compile.
$CCACHE $REAL_CCTC --core=tc1.6.2 --create=object test1.c
expect_stat preprocessed_cache_hit 0
expect_stat cache_miss 1
expect_stat files_in_cache 1
# expect_equal_content reference_test1.o test1.o

# Second compile.
$CCACHE $REAL_CCTC --core=tc1.6.2 --create=object test1.c
expect_stat preprocessed_cache_hit 1
expect_stat cache_miss 1
expect_stat files_in_cache 1
# expect_equal_content reference_test1.o test1.o

# Third compile, test output option
$CCACHE $REAL_CCTC --core=tc1.6.2 --output=test1.o --create=object test1.c
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 1
expect_stat files_in_cache 1
# expect_equal_content reference_test1.o test1.o

# Test for a different core -> parameter stays in the hash along with the preprocessor output
$CCACHE $REAL_CCTC --core=tc1.3 --create=object test1.c
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 2
expect_stat files_in_cache 2

# Test for a different core -> parameter stays in the hash along with the preprocessor output
$CCACHE $REAL_CCTC --core=tc1.3 --align=4 --create=object test1.c
expect_stat preprocessed_cache_hit 2
expect_stat cache_miss 3
expect_stat files_in_cache 3

# test with the same option in a file
echo "--core=tc1.3" > file.opt
echo "--align=4" >> file.opt
echo "--create=object " >> file.opt
$CCACHE $REAL_CCTC -f file.opt test1.c
expect_stat preprocessed_cache_hit 3
expect_stat cache_miss 3
expect_stat files_in_cache 3

$CCACHE $REAL_CCTC --option-file=file.opt test1.c
expect_stat preprocessed_cache_hit 4
expect_stat cache_miss 3
expect_stat files_in_cache 3

# -------------------------------------------------------------------------
TEST "Extra long CLI parameters"

mkdir -p subdir/src subdir/include
cat <<EOF >subdir/src/test.c
#include <test.h>
int foo(int x) { return test + x; }
EOF
cat <<EOF >subdir/include/test.h
int test;
EOF

# after creation of the file, wait a couple of seconds
sleep 2

unset CCACHE_NODIRECT

local i
local params=""
for ((i = 1; i <= 1000; i++)); do
params="$params -I subdir/include"
done

# fallback to original compiler
$CCACHE $REAL_CCTC $params -n --core=tc1.6.2 subdir/src/test.c
expect_stat output_to_stdout 1

remove_cache

# with arguments
$CCACHE $REAL_CCTC $params --core=tc1.6.2 --create=object subdir/src/test.c
expect_stat preprocessed_cache_hit 0
expect_stat direct_cache_hit 0
expect_stat direct_cache_miss 1
expect_stat cache_miss 1
expect_stat files_in_cache 2

rm -f optionfile
for ((i = 1; i <= 1000; i++)); do
echo " -I subdir/include" >>optionfile
done

remove_cache

# with option
$CCACHE $REAL_CCTC -f optionfile --core=tc1.6.2 --create=object subdir/src/test.c
expect_stat preprocessed_cache_hit 0
expect_stat direct_cache_hit 0
expect_stat direct_cache_miss 1
expect_stat cache_miss 1
expect_stat files_in_cache 2

return 0

}

SUITE_cctc_PROBE() {
cctc_PROBE
}

SUITE_cctc_SETUP() {
cctc_SETUP
}

SUITE_cctc() {
cctc_tests
}

0 comments on commit 9851d84

Please sign in to comment.