aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libtls-standalone/Makefile.am2
-rw-r--r--libtls-standalone/app/test.c6
-rw-r--r--libtls-standalone/configure.ac2
-rw-r--r--libtls-standalone/src/Makefile.am2
-rw-r--r--libtls-standalone/tests/Makefile.am (renamed from libtls-standalone/app/Makefile.am)3
-rw-r--r--libtls-standalone/tests/test.c51
6 files changed, 56 insertions, 10 deletions
diff --git a/libtls-standalone/Makefile.am b/libtls-standalone/Makefile.am
index 66fe845..2581717 100644
--- a/libtls-standalone/Makefile.am
+++ b/libtls-standalone/Makefile.am
@@ -1,4 +1,4 @@
1SUBDIRS = include compat src app man 1SUBDIRS = include compat src tests man
2ACLOCAL_AMFLAGS = -I m4 2ACLOCAL_AMFLAGS = -I m4
3 3
4pkgconfigdir = $(libdir)/pkgconfig 4pkgconfigdir = $(libdir)/pkgconfig
diff --git a/libtls-standalone/app/test.c b/libtls-standalone/app/test.c
deleted file mode 100644
index e3c3f76..0000000
--- a/libtls-standalone/app/test.c
+++ /dev/null
@@ -1,6 +0,0 @@
1#include <tls.h>
2
3int main()
4{
5 tls_init();
6}
diff --git a/libtls-standalone/configure.ac b/libtls-standalone/configure.ac
index e8fb24e..ebdd850 100644
--- a/libtls-standalone/configure.ac
+++ b/libtls-standalone/configure.ac
@@ -42,10 +42,10 @@ CHECK_LIBC_CRYPTO_COMPAT
42AC_CONFIG_FILES([ 42AC_CONFIG_FILES([
43 Makefile 43 Makefile
44 include/Makefile 44 include/Makefile
45 app/Makefile
46 compat/Makefile 45 compat/Makefile
47 man/Makefile 46 man/Makefile
48 src/Makefile 47 src/Makefile
48 tests/Makefile
49 libtls.pc 49 libtls.pc
50]) 50])
51 51
diff --git a/libtls-standalone/src/Makefile.am b/libtls-standalone/src/Makefile.am
index e821186..7844525 100644
--- a/libtls-standalone/src/Makefile.am
+++ b/libtls-standalone/src/Makefile.am
@@ -3,7 +3,7 @@ AM_CFLAGS = -I$(top_srcdir)/include
3lib_LTLIBRARIES = libtls.la 3lib_LTLIBRARIES = libtls.la
4 4
5libtls_la_LDFLAGS = -version-info @LIBTLS_VERSION@ -no-undefined 5libtls_la_LDFLAGS = -version-info @LIBTLS_VERSION@ -no-undefined
6libtls_la_LIBADD = -lcrypto -lssl $(PLATFORM_LDADD) 6libtls_la_LIBADD = -lcrypto -lssl -lcrypto $(PLATFORM_LDADD)
7libtls_la_LIBADD += $(top_builddir)/compat/libcompat.la 7libtls_la_LIBADD += $(top_builddir)/compat/libcompat.la
8libtls_la_LIBADD += $(top_builddir)/compat/libcompatnoopt.la 8libtls_la_LIBADD += $(top_builddir)/compat/libcompatnoopt.la
9 9
diff --git a/libtls-standalone/app/Makefile.am b/libtls-standalone/tests/Makefile.am
index 75a3dd6..1a08aef 100644
--- a/libtls-standalone/app/Makefile.am
+++ b/libtls-standalone/tests/Makefile.am
@@ -1,6 +1,7 @@
1AM_CFLAGS = -I$(top_srcdir)/include 1AM_CFLAGS = -I$(top_srcdir)/include
2 2
3bin_PROGRAMS = test 3check_PROGRAMS = test
4 4
5TESTS = test
5test_SOURCES = test.c 6test_SOURCES = test.c
6test_LDADD = -lcrypto -lssl $(top_builddir)/src/libtls.la 7test_LDADD = -lcrypto -lssl $(top_builddir)/src/libtls.la
diff --git a/libtls-standalone/tests/test.c b/libtls-standalone/tests/test.c
new file mode 100644
index 0000000..b2b7c67
--- /dev/null
+++ b/libtls-standalone/tests/test.c
@@ -0,0 +1,51 @@
1#include <stdio.h>
2#include <tls.h>
3
4int main()
5{
6 struct tls *tls;
7 struct tls_config *tls_config;
8 size_t written, read;
9 char buf[4096];
10
11 if (tls_init() != 0) {
12 fprintf(stderr, "tls_init failed");
13 return 1;
14 }
15
16 if ((tls = tls_client()) == NULL)
17 goto err;
18
19 if ((tls_config = tls_config_new()) == NULL)
20 goto err;
21
22 if (tls_config_set_ciphers(tls_config, "compat") != 0)
23 goto err;
24
25 tls_config_insecure_noverifycert(tls_config);
26 tls_config_insecure_noverifyname(tls_config);
27
28 if (tls_configure(tls, tls_config) != 0)
29 goto err;
30
31 if (tls_connect(tls, "google.com", "443") != 0)
32 goto err;
33
34 if (tls_write(tls, "GET /\r\n", 7, &written) != 0)
35 goto err;
36
37 if (tls_read(tls, buf, sizeof(buf), &read) != 0)
38 goto err;
39
40 buf[read - 1] = '\0';
41 puts(buf);
42
43 if (tls_close(tls) != 0)
44 goto err;
45
46 return 0;
47
48err:
49 fprintf(stderr, "%s\n", tls_error(tls));
50 return 0;
51}