integrate AES unit test into main build framework

Required addition of include/ directory for headers shared between
daemon and tests

Change-Id: Ib25504f4d7f4baa917efcdc0ef78b6cc89439827
pull/545/head
Richard Fuchs 8 years ago
parent 8c770b9e05
commit db2882ca78

@ -60,7 +60,7 @@ ifeq ($(with_iptables_option),yes)
CFLAGS+= $(shell pkg-config --cflags libiptc)
CFLAGS+= -DWITH_IPTABLES_OPTION
endif
CFLAGS+= -I. -I../kernel-module/ -I../lib/
CFLAGS+= -I. -I../kernel-module/ -I../lib/ -I../include/
CFLAGS+= -D_GNU_SOURCE
ifeq ($(with_transcoding),yes)
CFLAGS+= $(shell pkg-config --cflags libavcodec)

@ -24,6 +24,7 @@
struct packet_stream;
struct sockaddr_in6;
struct poller;
struct stream_fd;

@ -12,11 +12,11 @@ debug:
dep: .depend
clean:
rm -f $(OBJS) $(TARGET) $(LIBSRCS) $(ADD_CLEAN) .depend core core.*
rm -f $(OBJS) $(TARGET) $(LIBSRCS) $(DAEMONSRCS) $(ADD_CLEAN) .depend core core.*
rm -f fix_frame_channel_layout.h fix_frame_channel_layout-test.[co]
.depend: $(SRCS) $(LIBSRCS) Makefile
$(CC) $(CFLAGS) -M $(SRCS) $(LIBSRCS) | sed -e 's/:/ .depend:/' > .depend
.depend: $(SRCS) $(LIBSRCS) $(DAEMONSRCS) Makefile
$(CC) $(CFLAGS) -M $(SRCS) $(LIBSRCS) $(DAEMONSRCS) | sed -e 's/:/ .depend:/' > .depend
install:
@ -27,6 +27,11 @@ $(LIBSRCS): $(patsubst %,../lib/%,$(LIBSRCS))
echo '/******** GENERATED FILE ********/' > "$@"
cat ../lib/"$@" >> "$@"
$(DAEMONSRCS): $(patsubst %,../daemon/%,$(DAEMONSRCS))
rm -f "$@"
echo '/******** GENERATED FILE ********/' > "$@"
cat ../daemon/"$@" >> "$@"
resample.c: fix_frame_channel_layout.h
fix_frame_channel_layout.h: ../lib/fix_frame_channel_layout-*

2
t/.gitignore vendored

@ -11,3 +11,5 @@ loglib.c
resample.c
rtplib.c
str.c
crypto.c
aes-crypt

@ -22,6 +22,7 @@ flags = [
'-pthread',
'-I../kernel-module/',
'-I../lib/',
'-I../daemon/',
'-D_GNU_SOURCE',
'-D__DEBUG=1',
'-D__YCM=1',

@ -7,7 +7,7 @@ CFLAGS+= -std=c99
CFLAGS+= $(shell pkg-config --cflags glib-2.0)
CFLAGS+= $(shell pkg-config --cflags gthread-2.0)
CFLAGS+= $(shell pkg-config --cflags openssl)
CFLAGS+= -I. -I../lib/
CFLAGS+= -I. -I../lib/ -I../kernel-module/ -I../include/
CFLAGS+= -D_GNU_SOURCE
ifeq ($(with_transcoding),yes)
CFLAGS+= $(shell pkg-config --cflags libavcodec)
@ -32,7 +32,7 @@ LDLIBS+= $(shell pkg-config --libs libswresample)
LDLIBS+= $(shell pkg-config --libs libavfilter)
endif
SRCS= bitstr-test.c
SRCS= bitstr-test.c aes-crypt.c
ifeq ($(with_transcoding),yes)
SRCS+= amr-decode-test.c amr-encode-test.c
endif
@ -40,7 +40,10 @@ LIBSRCS= loglib.c auxlib.c str.c rtplib.c
ifeq ($(with_transcoding),yes)
LIBSRCS+= codeclib.c resample.c
endif
OBJS= $(SRCS:.c=.o) $(LIBSRCS:.c=.o)
DAEMONSRCS= crypto.c
OBJS= $(SRCS:.c=.o) $(LIBSRCS:.c=.o) $(DAEMONSRCS:.c=.o)
COMMONOBJS= str.o auxlib.o rtplib.o loglib.o
include ../lib/common.Makefile
@ -48,7 +51,7 @@ include .depend
.PHONY: unit-tests
TESTS= bitstr-test
TESTS= bitstr-test aes-crypt
ifeq ($(with_transcoding),yes)
TESTS+= amr-decode-test amr-encode-test
endif
@ -60,6 +63,8 @@ unit-tests: $(TESTS)
bitstr-test: bitstr-test.o
amr-decode-test: amr-decode-test.o codeclib.o str.o auxlib.o resample.o rtplib.o loglib.o
amr-decode-test: amr-decode-test.o $(COMMONOBJS) codeclib.o resample.o
amr-encode-test: amr-encode-test.o $(COMMONOBJS) codeclib.o resample.o
amr-encode-test: amr-encode-test.o codeclib.o str.o auxlib.o resample.o rtplib.o loglib.o
aes-crypt: aes-crypt.o $(COMMONOBJS) crypto.o

@ -3,6 +3,7 @@
#include "crypto.h"
#include "rtplib.h"
#include "log.h"
uint8_t test_key[46] = {
0xe1, 0xf9, 0x7a, 0x0d, 0x3e, 0x01, 0x8b, 0xe0,
@ -115,13 +116,13 @@ void srtp_validate (struct crypto_context *c, struct crypto_context *c2, char* m
uint8_t *rtcp_plaintext, uint8_t *rtcp_ciphertext)
{
str payload, hash;
uint8_t o_hash[10];
char o_hash[10];
uint8_t srtp_plaintext[38];
uint8_t srtp_ciphertext[38];
char srtp_plaintext[38];
char srtp_ciphertext[38];
uint8_t srtcp_plaintext[38];
uint8_t srtcp_ciphertext[38];
char srtcp_plaintext[38];
char srtcp_ciphertext[38];
memcpy(srtp_plaintext, plaintext, 28);
memcpy(srtp_ciphertext, ciphertext, 38);
@ -198,7 +199,6 @@ error:
int main(int argc, char** argv) {
str suite;
str s;
const struct crypto_suite *c;
struct crypto_context ctx, ctx2;

@ -1,38 +0,0 @@
##
## Build daemon/
## cd tests/
## make -f Makefile.aes, output is binary t_crypt
## run: ./t_crypt
CC = gcc
CPPFLAGS = -I../daemon -I../lib
OBJS_DIR = ../daemon/
OBJS = crypto.o log.o loglib.o
LDLIBS = $(shell pkg-config --libs glib-2.0)
LDLIBS += $(shell pkg-config --libs openssl)
CFLAGS = -g $(shell pkg-config --cflags glib-2.0) -D_GNU_SOURCE
%.d: %.c
@set -e; rm -f $@; \
$(CC) -M $(CPPFLAGS) $(shell pkg-config --cflags glib-2.0) -D_GNU_SOURCE $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
all: t_crypt
sources = t_crypt.c
include $(sources:.c=.d)
t_crypt: t_crypt.o
gcc $(LDFLAGS) -o $@ $< $(addprefix $(OBJS_DIR), $(OBJS)) $(LDLIBS)
.PHONY: clean
clean:
-rm -f t_crypt t_crypt.o
Loading…
Cancel
Save