This commit is contained in:
Caio Rordrigues 2016-12-06 08:45:06 +00:00 committed by GitHub
commit 201454be11
3 changed files with 111 additions and 0 deletions

33
.gitignore vendored Normal file
View File

@ -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/

57
Makefile Normal file
View File

@ -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

21
unit_test.sh Executable file
View File

@ -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 ""