Improved script for testing and fixed it to use /bin/sh

This commit is contained in:
g1n 2021-12-19 18:40:03 +02:00
parent fd21b5a8c2
commit 3c60dad466
3 changed files with 58 additions and 4 deletions

View File

@ -8,8 +8,7 @@
- to build examples run ~make examples~ with same arguments
* Tests
- run ~make tests~ with same arguments
- then run ~../tests/test.sh~ if you are in ~src/~ directory
- run ~make tests~ with same arguments (it will automaticly run script for testing)
- this will compare result from olibc with libc that installed by default on your machine
* Usage

View File

@ -43,4 +43,5 @@ tests:
$(CC) ../tests/string/memset.c $(CFLAGS) -o ../builds/tests/string/memset -l:olibc.a $(LIBFLAGS)
$(CC) ../tests/string/strpbrk.c $(CFLAGS) -o ../builds/tests/string/strpbrk -l:olibc.a $(LIBFLAGS)
$(CC) ../tests/string/strtok.c $(CFLAGS) -o ../builds/tests/string/strtok -l:olibc.a $(LIBFLAGS)
../tests/test.sh

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# Simple script for testing olibc
# Recommended to execute in directory tests/ or src/
@ -7,7 +7,59 @@ CC=cc
cd ../builds/tests
for i in $(ls); do
if [[ -z $@ ]]
then
headerslist=$(ls)
else
headerslist=$@
fi
if [ "$1" == "--help" ] || [ "$1" == "-h" ]
then
echo "Simple utility for testing olibc"
echo "- To run a test for some headers run this script with header names as argument (for example: ./test.sh string)"
echo "- To test all headers just run this script without arguments"
echo "Options:"
echo " -h | --help - display this message "
echo " -lh | --list-headers - display all headers that have tests"
echo " -lf | --list-functions - display all functions that have tests from header"
exit
elif [ "$1" == "--list-headers" ] || [ "$1" == "-lh" ]
then
for i in $(ls); do
if [ -d $i ]
then
echo $i
fi
done
exit
elif [ "$1" == "--list-functions" ] || [ "$1" == "-lf" ]
then
for i in $headerslist; do
if [ -d $i ]
then
cd $i
for j in $(ls); do
if [ -x $j ] && [[ $j != *"-cc"* ]]
then
echo "$i/$j"
fi
done
else
if [[ $i != "-"* ]]
then
echo "Tests for $i not found."
fi
fi
done
exit
elif [[ "$1" == "-"* ]]
then
echo "No such flag: $1, check --help for help"
exit
fi
for i in $headerslist; do
if [ -d $i ]
then
echo ------------------------
@ -32,6 +84,8 @@ for i in $(ls); do
echo "---"
fi
done
else
echo "Tests for $i not found."
fi
done