diff options
-rw-r--r-- | src/auction/Makefile.am | 37 | ||||
-rwxr-xr-x | src/auction/test_auction_create.sh | 80 |
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 | ||
6 | libexecdir= $(pkglibdir)/libexec/ | 6 | libexecdir= $(pkglibdir)/libexec/ |
7 | 7 | ||
8 | |||
8 | dist_pkgcfg_DATA = \ | 9 | dist_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 |
17 | endif | 18 | endif |
18 | 19 | ||
19 | # use bin_PROGRAMS for gnunet-auction wrapper script | ||
20 | 20 | ||
21 | libexec_PROGRAMS = \ | 21 | libexec_PROGRAMS = \ |
22 | gnunet-service-auction | ||
23 | |||
24 | gnunet_service_auction_SOURCES = \ | ||
25 | gnunet-service-auction.c | ||
26 | gnunet_service_auction_LDADD = \ | ||
27 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
28 | -ljansson \ | ||
29 | $(GN_LIBINTL) | ||
30 | |||
31 | |||
32 | bin_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 | ||
27 | gnunet_auction_create_SOURCES = \ | 37 | gnunet_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 | ||
48 | gnunet_service_auction_SOURCES = \ | ||
49 | gnunet-service-auction.c | ||
50 | gnunet_service_auction_LDADD = \ | ||
51 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
52 | -ljansson \ | ||
53 | $(GN_LIBINTL) | ||
54 | |||
55 | 58 | ||
56 | check_PROGRAMS = \ | 59 | check_PROGRAMS = \ |
57 | test_auction_api | 60 | test_auction_api |
58 | 61 | ||
59 | if ENABLE_TEST_RUN | ||
60 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH; | ||
61 | TESTS = $(check_PROGRAMS) | ||
62 | endif | ||
63 | |||
64 | test_auction_api_SOURCES = \ | 62 | test_auction_api_SOURCES = \ |
65 | test_auction_api.c | 63 | test_auction_api.c |
66 | test_auction_api_LDADD = \ | 64 | test_auction_api_LDADD = \ |
67 | $(top_builddir)/src/util/libgnunetutil.la | 65 | $(top_builddir)/src/util/libgnunetutil.la |
66 | |||
67 | |||
68 | check_SCRIPTS = \ | ||
69 | test_auction_create.sh | ||
70 | |||
71 | if ENABLE_TEST_RUN | ||
72 | AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH; | ||
73 | TESTS = $(check_PROGRAMS) $(check_SCRIPTS) | ||
74 | endif | ||
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 | |||
3 | trap 'rm -f test.json' EXIT | ||
4 | |||
5 | |||
6 | # missing required cmdline args | ||
7 | gnunet-auction-create -r 1 -d foo -p test.json && exit 1 | ||
8 | gnunet-auction-create -s 1 -d foo -p test.json && exit 1 | ||
9 | gnunet-auction-create -s 1 -r 1 -p test.json && exit 1 | ||
10 | gnunet-auction-create -s 1 -r 1 -d foo && exit 1 | ||
11 | |||
12 | |||
13 | # no pricemap | ||
14 | rm -f test.json | ||
15 | gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1 | ||
16 | |||
17 | |||
18 | # json errors | ||
19 | cat <<DOG >test.json | ||
20 | [,] | ||
21 | DOG | ||
22 | gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1 | ||
23 | |||
24 | cat <<DOG >test.json | ||
25 | bla | ||
26 | DOG | ||
27 | gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1 | ||
28 | |||
29 | |||
30 | # unexpected structures | ||
31 | cat <<DOG >test.json | ||
32 | {"foo": "bar"} | ||
33 | DOG | ||
34 | gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1 | ||
35 | |||
36 | cat <<DOG >test.json | ||
37 | {"currency": "foo"} | ||
38 | DOG | ||
39 | gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1 | ||
40 | |||
41 | cat <<DOG >test.json | ||
42 | {"prices": []} | ||
43 | DOG | ||
44 | gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1 | ||
45 | |||
46 | cat <<DOG >test.json | ||
47 | {"currency": "foo", "prices": "bar"} | ||
48 | DOG | ||
49 | gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1 | ||
50 | |||
51 | |||
52 | # wrong array content | ||
53 | cat <<DOG >test.json | ||
54 | {"currency": "foo", "prices": []} | ||
55 | DOG | ||
56 | gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1 | ||
57 | |||
58 | cat <<DOG >test.json | ||
59 | {"currency": "foo", "prices": ["bar"]} | ||
60 | DOG | ||
61 | gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1 | ||
62 | |||
63 | cat <<DOG >test.json | ||
64 | {"currency": "foo", "prices": [null]} | ||
65 | DOG | ||
66 | gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1 | ||
67 | |||
68 | cat <<DOG >test.json | ||
69 | {"currency": "foo", "prices": [1, 2]} | ||
70 | DOG | ||
71 | gnunet-auction-create -s 1 -r 1 -d foo -p test.json && exit 1 | ||
72 | |||
73 | |||
74 | # correct example | ||
75 | cat <<DOG >test.json | ||
76 | {"currency": "foo", "prices": [2, 1]} | ||
77 | DOG | ||
78 | gnunet-auction-create -s 1 -r 1 -d foo -p test.json || exit 1 | ||
79 | |||
80 | rm -f test.json | ||