diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..642ec29 --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +# Object files +*.o +*.ko +*.obj +*.elf + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex +*.bin + +# Debug files +*.dSYM/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..85c1c0c --- /dev/null +++ b/Makefile @@ -0,0 +1,57 @@ +# +# +# +# +# +# # +# This Makefile builds the Unit test executable and the # +# shared library: libslre.so # +# # +################################################################ + + +CC=gcc + +libname=libslre.so +unit_test=unit_test.bin +unit_test_shared=unit_test_shared.bin + +all: $(unit_test) $(libname) $(unit_test_shared) + + +# Unit test compiled without shared library +# +$(unit_test): + $(CC) -c slre.c + $(CC) -c unit_test.c + $(CC) -o unit_test.bin slre.o unit_test.o + @echo "Done. OK! run $ make test" + +# Unit Test compiled with shared library +# +$(unit_test_shared): $(libname) + gcc -c unit_test.c + gcc -L$(shell pwd) -Wall -o unit_test_shared.bin unit_test.o -lslre + +# Build shared library +# +$(libname): + $(CC) -fPIC -g -c slre.c + $(CC) -shared -Wl,-soname,$(libname) -o $(libname) slre.o -lc + +tests: $(unit_test) $(unit_test_shared) + bash unit_test.sh + + +install: $(libname) + cp $(shell pwd)/slre.h /usr/include/slre.h + cp $(shell pwd)/$(libname) /usr/lib/$(libname) + +uninstall: + rm -rf /usr/include/slre.h + rm -rf /usr/lib/$(lib) + +clean: + @rm -rf *.o *.bin *.out *.so + + diff --git a/unit_test.sh b/unit_test.sh new file mode 100755 index 0000000..a491b79 --- /dev/null +++ b/unit_test.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# Test library +# +#-------------------------- +echo "Running Unit test" +echo "" +./unit_test.bin +echo "" +echo "" + +# Test shared library Wrapper +# +export LD_LIBRARY_PATH=$(pwd):$LD_LIBRARY_PATH + +echo "Running Shared Library Unit Test" +echo "" +./unit_test_shared.bin +echo "" +echo "" +