mirror of
https://github.com/Noratrieb/libuwuc.git
synced 2026-01-14 11:45:05 +01:00
tests
This commit is contained in:
parent
9d74d9120c
commit
2f0191768f
6 changed files with 44 additions and 6 deletions
|
|
@ -2,6 +2,7 @@
|
|||
buildInputs = with pkgs; [
|
||||
rustup
|
||||
gcc
|
||||
clang_16
|
||||
];
|
||||
shellHook = ''
|
||||
export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin
|
||||
|
|
|
|||
21
test_c.sh
21
test_c.sh
|
|
@ -12,8 +12,18 @@ clean() {
|
|||
|
||||
for test in tests/c/*; do
|
||||
name=$(basename $test .c)
|
||||
printf "test $name "
|
||||
|
||||
"$SCRIPT_DIR/uwuc-gcc" "$test" -o "$test_dir/$name"
|
||||
flags=$(grep "//@flags: " "$test" | sed 's#//@flags: ##')
|
||||
|
||||
grep "//@ignore" "$test" >/dev/null
|
||||
ignore=$?
|
||||
if [ "$ignore" -eq "0" ]; then
|
||||
echo -e "\e[33mIGNORE\e[0m"
|
||||
continue
|
||||
fi
|
||||
|
||||
"$SCRIPT_DIR/uwuc-gcc" $flags "$test" -o "$test_dir/$name"
|
||||
|
||||
if [ "$?" -ne "0" ]; then
|
||||
echo "error: failed to compile test $test"
|
||||
|
|
@ -21,16 +31,15 @@ for test in tests/c/*; do
|
|||
exit 1
|
||||
fi
|
||||
|
||||
printf "test $name "
|
||||
|
||||
OUTPUT=$("$test_dir/$name")
|
||||
code="$?"
|
||||
if [ "$code" -ne "0" ]; then
|
||||
echo -e "\e[31mFAIL\e[0m"
|
||||
echo "error: test failed with code $code: $test, running $test_dir/$name"
|
||||
echo "------ output:"
|
||||
echo "$OUTPUT"
|
||||
echo "-----"
|
||||
echo "error: test failed with code $code: $test, compiled with $flags"
|
||||
echo "------output"
|
||||
echo -n "$OUTPUT"
|
||||
echo "------"
|
||||
else
|
||||
echo -e "\e[32mPASS\e[0m"
|
||||
fi
|
||||
|
|
|
|||
7
tests/c/errno.c
Normal file
7
tests/c/errno.c
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
//@ignore doens't initialize fs yet
|
||||
#include<errno.h>
|
||||
|
||||
int main(void) {
|
||||
int err = errno;
|
||||
return err;
|
||||
}
|
||||
5
tests/c/stack_prot.c
Normal file
5
tests/c/stack_prot.c
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
//@flags: -fstack-protector-all
|
||||
//@ignore no support yet
|
||||
|
||||
int main(void) {}
|
||||
9
tests/c/strtol.c
Normal file
9
tests/c/strtol.c
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#include<stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
char *str = "12";
|
||||
long value = strtol(str, NULL, 10);
|
||||
if (value != 12) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
7
uwuc-clang
Executable file
7
uwuc-clang
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
args=("-nodefaultlibs" "-nostdlib" "-L${SCRIPT_DIR}/target/debug" "-lrawc")
|
||||
|
||||
exec clang "$@" "${args[@]}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue