aboutsummaryrefslogtreecommitdiff
path: root/src/auction
diff options
context:
space:
mode:
authorMarkus Teich <teichm@fs.tum.de>2017-01-12 20:17:35 +0100
committerMarkus Teich <teichm@fs.tum.de>2017-01-12 20:18:09 +0100
commitcdb78737878d73db365e2af9be5729d39fbab2bb (patch)
tree4e736f385b26d12d1ea9ddb775d0d292494fbaa1 /src/auction
parent9006be70fd75641136a5a230f613498d5082bb3d (diff)
downloadgnunet-cdb78737878d73db365e2af9be5729d39fbab2bb.tar.gz
gnunet-cdb78737878d73db365e2af9be5729d39fbab2bb.zip
auction: add test for auction-create
Diffstat (limited to 'src/auction')
-rw-r--r--src/auction/Makefile.am37
-rwxr-xr-xsrc/auction/test_auction_create.sh80
2 files changed, 102 insertions, 15 deletions
diff --git a/src/auction/Makefile.am b/src/auction/Makefile.am
index 8518244fa..0c250a0b4 100644
--- a/src/auction/Makefile.am
+++ b/src/auction/Makefile.am
@@ -5,6 +5,7 @@ pkgcfgdir= $(pkgdatadir)/config.d/
5 5
6libexecdir= $(pkglibdir)/libexec/ 6libexecdir= $(pkglibdir)/libexec/
7 7
8
8dist_pkgcfg_DATA = \ 9dist_pkgcfg_DATA = \
9 auction.conf 10 auction.conf
10 11
@@ -16,13 +17,22 @@ if USE_COVERAGE
16 AM_CFLAGS = -fprofile-arcs -ftest-coverage 17 AM_CFLAGS = -fprofile-arcs -ftest-coverage
17endif 18endif
18 19
19# use bin_PROGRAMS for gnunet-auction wrapper script
20 20
21libexec_PROGRAMS = \ 21libexec_PROGRAMS = \
22 gnunet-service-auction
23
24gnunet_service_auction_SOURCES = \
25 gnunet-service-auction.c
26gnunet_service_auction_LDADD = \
27 $(top_builddir)/src/util/libgnunetutil.la \
28 -ljansson \
29 $(GN_LIBINTL)
30
31
32bin_PROGRAMS = \
22 gnunet-auction-create \ 33 gnunet-auction-create \
23 gnunet-auction-info \ 34 gnunet-auction-info \
24 gnunet-auction-join \ 35 gnunet-auction-join
25 gnunet-service-auction
26 36
27gnunet_auction_create_SOURCES = \ 37gnunet_auction_create_SOURCES = \
28 gnunet-auction-create.c 38 gnunet-auction-create.c
@@ -45,23 +55,20 @@ gnunet_auction_join_LDADD = \
45 -ljansson \ 55 -ljansson \
46 $(GN_LIBINTL) 56 $(GN_LIBINTL)
47 57
48gnunet_service_auction_SOURCES = \
49 gnunet-service-auction.c
50gnunet_service_auction_LDADD = \
51 $(top_builddir)/src/util/libgnunetutil.la \
52 -ljansson \
53 $(GN_LIBINTL)
54
55 58
56check_PROGRAMS = \ 59check_PROGRAMS = \
57 test_auction_api 60 test_auction_api
58 61
59if ENABLE_TEST_RUN
60AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;
61TESTS = $(check_PROGRAMS)
62endif
63
64test_auction_api_SOURCES = \ 62test_auction_api_SOURCES = \
65 test_auction_api.c 63 test_auction_api.c
66test_auction_api_LDADD = \ 64test_auction_api_LDADD = \
67 $(top_builddir)/src/util/libgnunetutil.la 65 $(top_builddir)/src/util/libgnunetutil.la
66
67
68check_SCRIPTS = \
69 test_auction_create.sh
70
71if ENABLE_TEST_RUN
72AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;
73TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
74endif
diff --git a/src/auction/test_auction_create.sh b/src/auction/test_auction_create.sh
new file mode 100755
index 000000000..b0f4de738
--- /dev/null
+++ b/src/auction/test_auction_create.sh
@@ -0,0 +1,80 @@
1#! /bin/sh
2
3trap 'rm -f test.json' EXIT
4
5
6# missing required cmdline args
7gnunet-auction-create -r 1 -d foo -p test.json && exit 1
8gnunet-auction-create -s 1 -d foo -p test.json && exit 1
9gnunet-auction-create -s 1 -r 1 -p test.json && exit 1
10gnunet-auction-create -s 1 -r 1 -d foo && exit 1
11
12
13# no pricemap
14rm -f test.json
15gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
16
17
18# json errors
19cat <<DOG >test.json
20[,]
21DOG
22gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
23
24cat <<DOG >test.json
25bla
26DOG
27gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
28
29
30# unexpected structures
31cat <<DOG >test.json
32{"foo": "bar"}
33DOG
34gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
35
36cat <<DOG >test.json
37{"currency": "foo"}
38DOG
39gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
40
41cat <<DOG >test.json
42{"prices": []}
43DOG
44gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
45
46cat <<DOG >test.json
47{"currency": "foo", "prices": "bar"}
48DOG
49gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
50
51
52# wrong array content
53cat <<DOG >test.json
54{"currency": "foo", "prices": []}
55DOG
56gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
57
58cat <<DOG >test.json
59{"currency": "foo", "prices": ["bar"]}
60DOG
61gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
62
63cat <<DOG >test.json
64{"currency": "foo", "prices": [null]}
65DOG
66gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
67
68cat <<DOG >test.json
69{"currency": "foo", "prices": [1, 2]}
70DOG
71gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1
72
73
74# correct example
75cat <<DOG >test.json
76{"currency": "foo", "prices": [2, 1]}
77DOG
78gnunet-auction-create -s 1 -r 1 -d foo -p test.json || exit 1
79
80rm -f test.json