forked from intel/tsffs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add C harnesses and compile tests for gcc/clang, update harness metho…
…d for unlimited indices
- Loading branch information
1 parent
e8851a8
commit e14afdf
Showing
11 changed files
with
5,217 additions
and
421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) | ||
|
||
cat <<EOF > "${SCRIPT_DIR}/tsffs.h" | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
#ifdef __GNUC__ | ||
#ifdef __i386__ | ||
$(cat "${SCRIPT_DIR}/tsffs-gcc-x86.h") | ||
#elif __x86_64__ | ||
$(cat "${SCRIPT_DIR}/tsffs-gcc-x86_64.h") | ||
#elif __riscv && !__LP64__ | ||
$(cat "${SCRIPT_DIR}/tsffs-gcc-riscv32.h") | ||
#elif __riscv && __LP64__ | ||
$(cat "${SCRIPT_DIR}/tsffs-gcc-riscv64.h") | ||
#elif __aarch64__ | ||
$(cat "${SCRIPT_DIR}/tsffs-gcc-aarch64.h") | ||
#elif __arm__ | ||
$(cat "${SCRIPT_DIR}/tsffs-gcc-arm32.h") | ||
#endif | ||
#endif | ||
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#ifdef SINGLE_FILE | ||
#include "tsffs.h" | ||
#else | ||
#ifdef __i386__ | ||
#include "tsffs-gcc-x86.h" | ||
#elif __x86_64__ | ||
#include "tsffs-gcc-x86_64.h" | ||
#elif __riscv && !__LP64__ | ||
#include "tsffs-gcc-riscv32.h" | ||
#elif __riscv && __LP64__ | ||
#include "tsffs-gcc-riscv64.h" | ||
#elif __aarch64__ | ||
#include "tsffs-gcc-aarch64.h" | ||
#elif __arm__ | ||
#include "tsffs-gcc-arm32.h" | ||
#endif | ||
#endif | ||
|
||
#include <stddef.h> | ||
|
||
int test_start() { | ||
char buf[1024]; | ||
size_t size = 1024; | ||
HARNESS_START(buf, &size); | ||
return 0; | ||
} | ||
|
||
int test_start_with_maximum_size() { | ||
char buf[1024]; | ||
size_t size = 1024; | ||
HARNESS_START_WITH_MAXIMUM_SIZE(buf, size); | ||
return 0; | ||
} | ||
|
||
int test_start_with_maximum_size_and_ptr() { | ||
char buf[1024]; | ||
size_t size = 1024; | ||
HARNESS_START_WITH_MAXIMUM_SIZE_AND_PTR(buf, &size, 1024); | ||
return 0; | ||
} | ||
|
||
int test_stop() { | ||
char buf[1024]; | ||
size_t size = 1024; | ||
HARNESS_STOP(); | ||
return 0; | ||
} | ||
|
||
int test_assert() { | ||
char buf[1024]; | ||
size_t size = 1024; | ||
HARNESS_ASSERT(); | ||
return 0; | ||
} | ||
|
||
#ifndef __arm__ | ||
int test_start_index() { | ||
char buf[1024]; | ||
size_t size = 1024; | ||
HARNESS_START_INDEX(1, buf, &size); | ||
return 0; | ||
} | ||
|
||
int test_start_with_maximum_size_index() { | ||
char buf[1024]; | ||
size_t size = 1024; | ||
HARNESS_START_WITH_MAXIMUM_SIZE_INDEX(2, buf, size); | ||
return 0; | ||
} | ||
|
||
int test_start_with_maximum_size_and_ptr_index() { | ||
char buf[1024]; | ||
size_t size = 1024; | ||
HARNESS_START_WITH_MAXIMUM_SIZE_AND_PTR_INDEX(3, buf, &size, 1024); | ||
return 0; | ||
} | ||
|
||
int test_stop_index() { | ||
char buf[1024]; | ||
size_t size = 1024; | ||
HARNESS_STOP_INDEX(4); | ||
return 0; | ||
} | ||
|
||
int test_assert_index() { | ||
char buf[1024]; | ||
size_t size = 1024; | ||
HARNESS_ASSERT_INDEX(5); | ||
return 0; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Compile test.c for each of x86, x86_64, riscv32, riscv64 architecture | ||
|
||
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) | ||
|
||
set -e | ||
|
||
"${SCRIPT_DIR}/build.sh" | ||
|
||
rm -f "${SCRIPT_DIR}/test_x86_64-clang.o" || exit 0 | ||
rm -f "${SCRIPT_DIR}/test_x86-clang.o" || exit 0 | ||
rm -f "${SCRIPT_DIR}/test_riscv32-clang.o" || exit 0 | ||
rm -f "${SCRIPT_DIR}/test_riscv64-clang.o" || exit 0 | ||
rm -f "${SCRIPT_DIR}/test_x86_64-gcc.o" || exit 0 | ||
rm -f "${SCRIPT_DIR}/test_x86-gcc.o" || exit 0 | ||
rm -rf "${SCRIPT_DIR}/test_aarch64-clang.o" || exit 0 | ||
rm -rf "${SCRIPT_DIR}/test_arm32-clang.o" || exit 0 | ||
rm -f "${SCRIPT_DIR}/test_x86_64-clang-single-file.o" || exit 0 | ||
rm -f "${SCRIPT_DIR}/test_x86-clang-single-file.o" || exit 0 | ||
rm -f "${SCRIPT_DIR}/test_riscv32-clang-single-file.o" || exit 0 | ||
rm -f "${SCRIPT_DIR}/test_riscv64-clang-single-file.o" || exit 0 | ||
rm -f "${SCRIPT_DIR}/test_x86_64-gcc-single-file.o" || exit 0 | ||
rm -f "${SCRIPT_DIR}/test_x86-gcc-single-file.o" || exit 0 | ||
rm -rf "${SCRIPT_DIR}test_aarch64-clang-single-file.o" || exit 0 | ||
rm -rf "${SCRIPT_DIR}test_arm32-clang-single-file.o" || exit 0 | ||
|
||
echo "Testing x86_64 (single file)..." | ||
clang -target x86_64-unknown-linux-gnu -DSINGLE_FILE=1 -g -c "${SCRIPT_DIR}/test.c" -o "${SCRIPT_DIR}/test_x86_64-clang-single-file.o" | ||
echo "Testing i386 (single file)..." | ||
clang -target i386-unknown-linux-gnu -DSINGLE_FILE=1 -g -c "${SCRIPT_DIR}/test.c" -o "${SCRIPT_DIR}/test_x86-clang-single-file.o" | ||
echo "Testing riscv32 (single file)..." | ||
clang -target riscv32-unknown-linux-gnu -DSINGLE_FILE=1 -g -c "${SCRIPT_DIR}/test.c" -o "${SCRIPT_DIR}/test_riscv32-clang-single-file.o" | ||
echo "Testing riscv64 (single file)..." | ||
clang -target riscv64-unknown-linux-gnu -DSINGLE_FILE=1 -g -c "${SCRIPT_DIR}/test.c" -o "${SCRIPT_DIR}/test_riscv64-clang-single-file.o" | ||
echo "Testing aarch64 (single file)..." | ||
clang -target aarch64-unknown-linux-gnu -DSINGLE_FILE=1 -g -c "${SCRIPT_DIR}/test.c" -o "${SCRIPT_DIR}/test_aarch64-clang-single-file.o" | ||
echo "Testing arm (single file)..." | ||
clang -target arm-unknown-linux-gnu -mfloat-abi=soft -DSINGLE_FILE=1 -g -c "${SCRIPT_DIR}/test.c" -o "${SCRIPT_DIR}/test_arm32-clang-single-file.o" | ||
echo "Testing x86_64 (single file, gcc)..." | ||
gcc -DSINGLE_FILE=1 -g -c "${SCRIPT_DIR}/test.c" -o "${SCRIPT_DIR}/test_x86_64-gcc.o" | ||
echo "Testing i386 (single file, gcc)..." | ||
gcc -DSINGLE_FILE=1 -g -m32 -c "${SCRIPT_DIR}/test.c" -o "${SCRIPT_DIR}/test_x86-gcc.o" | ||
echo "Testing x86_64 (multi file)..." | ||
clang -target x86_64-unknown-linux-gnu -g -c "${SCRIPT_DIR}/test.c" -o "${SCRIPT_DIR}/test_x86_64-clang.o" | ||
echo "Testing i386 (multi file)..." | ||
clang -target i386-unknown-linux-gnu -g -c "${SCRIPT_DIR}/test.c" -o "${SCRIPT_DIR}/test_x86-clang.o" | ||
echo "Testing riscv32(multi file)..." | ||
clang -target riscv32-unknown-linux-gnu -g -c "${SCRIPT_DIR}/test.c" -o "${SCRIPT_DIR}/test_riscv32-clang.o" | ||
echo "Testing riscv64(multi file)..." | ||
clang -target riscv64-unknown-linux-gnu -g -c "${SCRIPT_DIR}/test.c" -o "${SCRIPT_DIR}/test_riscv64-clang.o" | ||
echo "Testing aarch64 (multi file)..." | ||
clang -target aarch64-unknown-linux-gnu -g -c "${SCRIPT_DIR}/test.c" -o "${SCRIPT_DIR}/test_aarch64-clang.o" | ||
echo "Testing arm (multi file)..." | ||
clang -target arm-unknown-linux-gnu -mfloat-abi=soft -g -c "${SCRIPT_DIR}/test.c" -o "${SCRIPT_DIR}/test_arm32-clang.o" | ||
echo "Testing x86_64 (multi file, gcc)..." | ||
gcc -g -c "${SCRIPT_DIR}/test.c" -o "${SCRIPT_DIR}/test_x86_64-gcc.o" | ||
echo "Testing i386(multi file, gcc)..." | ||
gcc -g -m32 -c "${SCRIPT_DIR}/test.c" -o "${SCRIPT_DIR}/test_x86-gcc.o" |
Oops, something went wrong.