mirror of
https://github.com/cesanta/slre.git
synced 2025-03-13 17:05:31 +00:00
Makefile builds and test shared libraries, added unit_test.sh
This commit is contained in:
parent
9c5602e8c9
commit
7b24ccd083
50
Makefile
50
Makefile
@ -3,33 +3,55 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
# #
|
||||||
#
|
# This Makefile builds the Unit test executable and the #
|
||||||
#
|
# shared library: libslre.so #
|
||||||
#
|
# #
|
||||||
#
|
################################################################
|
||||||
#
|
|
||||||
#####################################################
|
|
||||||
|
|
||||||
|
|
||||||
CC=gcc
|
CC=gcc
|
||||||
|
|
||||||
all: unit_test lib
|
libname=libslre.so
|
||||||
|
unit_test=unit_test.bin
|
||||||
|
unit_test_shared=unit_test_shared.bin
|
||||||
|
|
||||||
unit_test:
|
all: $(unit_test) $(libname) $(unit_test_shared)
|
||||||
|
|
||||||
|
|
||||||
|
# Unit test compiled without shared library
|
||||||
|
#
|
||||||
|
$(unit_test):
|
||||||
$(CC) -c slre.c
|
$(CC) -c slre.c
|
||||||
$(CC) -c unit_test.c
|
$(CC) -c unit_test.c
|
||||||
$(CC) -o unit_test.bin slre.o unit_test.o
|
$(CC) -o unit_test.bin slre.o unit_test.o
|
||||||
@echo "Done. OK! run $ make test"
|
@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
|
||||||
|
|
||||||
lib:
|
# Build shared library
|
||||||
|
#
|
||||||
|
$(libname):
|
||||||
$(CC) -fPIC -g -c slre.c
|
$(CC) -fPIC -g -c slre.c
|
||||||
$(CC) -shared -Wl,-soname,libslre.so -o libslre.so slre.o -lc
|
$(CC) -shared -Wl,-soname,$(libname) -o $(libname) slre.o -lc
|
||||||
|
|
||||||
test:
|
tests: $(unit_test) $(unit_test_shared)
|
||||||
@echo "Running unit_test.bin"
|
bash unit_test.sh
|
||||||
./unit_test.bin
|
|
||||||
|
|
||||||
|
install:
|
||||||
|
sudo cp slre.h /usr/include/slre.h
|
||||||
|
sudo cp $(lib) /usr/lib/$(lib)
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
rm -rf /usr/include/slre.h
|
||||||
|
rm -rf /usr/lib/$(lib)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@rm -rf *.o *.bin *.out *.so
|
@rm -rf *.o *.bin *.out *.so
|
||||||
|
|
||||||
|
|
||||||
|
21
unit_test.sh
Executable file
21
unit_test.sh
Executable 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 ""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user