diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2017-05-11 22:12:08 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2017-05-11 22:12:08 +0200 |
commit | e382b70880fe82176a086f909a027a2f85a884b6 (patch) | |
tree | bb78d2fdf655d17de59000db7eea4c6bcad2ca29 /tests | |
parent | 30596991abc9e452fbad8372f1ddcce12b87ce72 (diff) | |
download | abaos-e382b70880fe82176a086f909a027a2f85a884b6.tar.gz abaos-e382b70880fe82176a086f909a027a2f85a884b6.tar.bz2 |
added strlcpy (and a host test for it)
started to add I/O port code for VGA data and select ports
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile | 23 | ||||
-rw-r--r-- | tests/test_strlcpy.c | 15 |
2 files changed, 38 insertions, 0 deletions
diff --git a/tests/Makefile b/tests/Makefile new file mode 100644 index 0000000..af20182 --- /dev/null +++ b/tests/Makefile @@ -0,0 +1,23 @@ +CC := gcc +CFLAGS := -std=c99 -m32 -ffreestanding -O0 -g -Wall -Werror +INCLUDES = -I../src +LD := ld + +all: test + +test_strlcpy: test_strlcpy.o + +test_strlcpy: test_strlcpy.o ../src/string.o + $(CC) -o test_strlcpy test_strlcpy.o ../src/string.o + +test_strlcpy.o: test_strlcpy.c + $(CC) $(CFLAGS) $(INCLUDES) -c -o test_strlcpy.o test_strlcpy.c + +../src/string.o: ../src/string.c + $(CC) $(CFLAGS) -c -o ../src/string.o ../src/string.c + +test: test_strlcpy + ./test_strlcpy + +clean: + -rm -f test_strlcpy *.o diff --git a/tests/test_strlcpy.c b/tests/test_strlcpy.c new file mode 100644 index 0000000..a23a5bc --- /dev/null +++ b/tests/test_strlcpy.c @@ -0,0 +1,15 @@ +#include "string.h" + +int main( void ) +{ + char *s = "test_string"; + char d[8]; + size_t n; + + // copy into too small string + n = strlcpy( d, s, 4 ); + if( n != 11 ) return 1; + if( strcmp( d, "tes" ) ) return 1; + + return 0; +} |