test and Make
authorVolker Birk <vb@pep-project.org>
Mon, 16 May 2016 17:53:24 +0200
changeset 637d93d1fe6a24c
parent 636 7c1ed9b320da
child 638 904464a12ab6
test and Make
Makefile
asn.1/Makefile
src/Makefile
test/sequence_test.cc
     1.1 --- a/Makefile	Mon May 16 16:38:38 2016 +0200
     1.2 +++ b/Makefile	Mon May 16 17:53:24 2016 +0200
     1.3 @@ -1,11 +1,13 @@
     1.4  include Makefile.conf
     1.5  
     1.6  all:
     1.7 +	$(MAKE) -C asn.1 generate
     1.8 +	$(MAKE) -C asn.1
     1.9  	$(MAKE) -C src all
    1.10  
    1.11  .PHONY: clean build_test test package install uninstall db
    1.12  
    1.13 -install:
    1.14 +install: all
    1.15  	$(MAKE) -C src install
    1.16  
    1.17  uninstall:
    1.18 @@ -15,6 +17,7 @@
    1.19  	$(MAKE) -C src clean
    1.20  	$(MAKE) -C test clean
    1.21  	$(MAKE) -C db clean
    1.22 +	$(MAKE) -C asn.1 clean
    1.23  
    1.24  test: all
    1.25  	$(MAKE) -C test test
     2.1 --- a/asn.1/Makefile	Mon May 16 16:38:38 2016 +0200
     2.2 +++ b/asn.1/Makefile	Mon May 16 17:53:24 2016 +0200
     2.3 @@ -1,14 +1,21 @@
     2.4  include ../Makefile.conf
     2.5  
     2.6 -all: DeviceGroup-Protocol.c
     2.7 +ALL_SOURCE=$(subst $(NO_SOURCE),,$(wildcard *.c))
     2.8 +ALL_OBJECTS=$(subst .c,.o,$(ALL_SOURCE))
     2.9 +
    2.10 +libasn1.a: $(ALL_OBJECTS)
    2.11 +	ar -rc $@ $(ALL_OBJECTS)
    2.12 +
    2.13 +generate: DeviceGroup-Protocol.c
    2.14 +	rm -f converter-sample.c
    2.15  
    2.16  %.o: %.c %.h
    2.17 -	$(CC) $(CFLAGS) -I$(ASN1C_INCLUDE) -c $< -o $@
    2.18 +	$(CC) $(CFLAGS) $(OPTIMIZE) -I$(ASN1C_INCLUDE) -c $< -o $@
    2.19  
    2.20  DeviceGroup-Protocol.c: devicegroup.asn1
    2.21 -	$(ASN1C) -fcompound-names -pdu=PEP.Message pEp.asn1 $<
    2.22 +	$(ASN1C) -fincludes-quoted -fcompound-names -pdu=PEP.Message pEp.asn1 $<
    2.23  
    2.24  .PHONY: clean
    2.25  
    2.26  clean:
    2.27 -	rm -f *.o *.c *.h *.sample
    2.28 +	rm -f *.a *.o *.c *.h *.sample
     3.1 --- a/src/Makefile	Mon May 16 16:38:38 2016 +0200
     3.2 +++ b/src/Makefile	Mon May 16 17:53:24 2016 +0200
     3.3 @@ -14,7 +14,7 @@
     3.4  CFLAGS?=-I$(GPGME_IN)/include -I$(HOME)/include -I/opt/local/include $(OPTIMIZE) -pedantic \
     3.5  	-DSYSTEM_DB=\"$(SYSTEM_DB)\" -DLIBGPGME=\"$(LIBGPGME)\"
     3.6  LDFLAGS?=-lc -shared -arch x86_64 \
     3.7 -	-L$(HOME)/lib -L/opt/local/lib -letpan -lsqlite3
     3.8 +	-L$(HOME)/lib -L/opt/local/lib -letpan -lsqlite3 -L../asn.1 -lasn1
     3.9  
    3.10  else
    3.11  $(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
    3.12 @@ -30,7 +30,7 @@
    3.13  CFLAGS?=-I$(GPGME_IN)/include $(OPTIMIZE) -fPIC -pedantic \
    3.14  	-DSYSTEM_DB=\"$(SYSTEM_DB)\" -DLIBGPGME=\"$(LIBGPGME)\" \
    3.15  	-DSQLITE_THREADSAFE=1 -D_GNU_SOURCE
    3.16 -LDFLAGS?=-L$(GPGME_IN)/lib -shared -lc -ldl -letpan -lpthread
    3.17 +LDFLAGS?=-L$(GPGME_IN)/lib -shared -lc -ldl -letpan -lpthread -L../asn.1 -lasn1
    3.18  
    3.19  else
    3.20  $(error don't know how to make for $(BUILD_FOR) on $(BUILD_ON))
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/test/sequence_test.cc	Mon May 16 17:53:24 2016 +0200
     4.3 @@ -0,0 +1,38 @@
     4.4 +#include <iostream>
     4.5 +#include <string>
     4.6 +#include <assert.h>
     4.7 +#include "pEpEngine.h"
     4.8 +
     4.9 +using namespace std;
    4.10 +
    4.11 +int main() {
    4.12 +    cout << "\n*** sequence_test ***\n\n";
    4.13 +
    4.14 +    PEP_SESSION session;
    4.15 +    
    4.16 +    cout << "calling init()\n";
    4.17 +    PEP_STATUS status1 = init(&session);   
    4.18 +    assert(status1 == PEP_STATUS_OK);
    4.19 +    assert(session);
    4.20 +    cout << "init() completed.\n";
    4.21 +
    4.22 +    // sequence test code
    4.23 +
    4.24 +    int64_t value1;
    4.25 +    PEP_STATUS status2 = sequence_value(session, "test", &value1);
    4.26 +    assert(status2 == PEP_STATUS_OK);
    4.27 +
    4.28 +    cout << "test sequence: " << value1 << "\n";
    4.29 +
    4.30 +    int64_t value2;
    4.31 +    PEP_STATUS status3 = sequence_value(session, "test", &value2);
    4.32 +    assert(status3 == PEP_STATUS_OK);
    4.33 +
    4.34 +    cout << "test sequence: " << value2 << "\n";
    4.35 +    assert(value2 == value1 + 1);
    4.36 +
    4.37 +    cout << "calling release()\n";
    4.38 +    release(session);
    4.39 +    return 0;
    4.40 +}
    4.41 +