Commit 7b860e03 authored by David Goulet's avatar David Goulet Committed by Ian Goldberg
Browse files

Test: Add new test-suite in tests/

This is a completely new test suite that adds unit and regression tests.
Still not everything is covered but it's at 76.3% line coverage and
87.5% function coverage. See the current status here.

	https://coverage.otr.im/



In order to run the tests, simply type "make check" from the top
directory of the repository.

The test suite uses libtap and adds both a shell and C library located
in tests/utils/tap.

Note that this test suite is not related at all to the tests located in
the directory test_suite. Future work should be done to either merge
them or remove the old one.

Tested with libgcrypt 1.5.4 and 1.6.2.
Signed-off-by: jvoisin's avatarJulien Voisin <julien.voisin@dustri.org>
Signed-off-by: default avatarDavid Goulet <dgoulet@ev0ke.net>
Signed-off-by: default avatarIan Goldberg <iang@cs.uwaterloo.ca>

Fixes #8
parent 187a09ac
......@@ -15,6 +15,8 @@ Makefile.in
*.info
*.gz
*.tar
*.gcda
*.gcno
.dirstamp
configure
aclocal.m4
......@@ -38,3 +40,17 @@ libotr.pc
/toolkit/otr_readforge
/toolkit/otr_remac
/toolkit/otr_sesskeys
/tests/regression/client/client
/tests/unit/test_auth
/tests/unit/test_proto
/tests/unit/test_dh
/tests/unit/test_b64
/tests/unit/test_context
/tests/unit/test_userstate
/tests/unit/test_tlv
/tests/unit/test_mem
/tests/unit/test_sm
/tests/unit/test_instag
/tests/unit/test_privkey
ACLOCAL_AMFLAGS = -I config
SUBDIRS = src toolkit
SUBDIRS = src toolkit tests
EXTRA_DIST = Protocol-v3.html UPGRADING packaging libotr.m4 libotr.pc.in
......
......@@ -170,11 +170,11 @@ if test x$enable_linker_hardening != xno; then
OTR_CHECK_LDFLAGS(-z relro -z now, "$all_ldflags_for_check", "$all_libs_for_check")
fi
AC_CONFIG_FILES([
Makefile
src/Makefile
toolkit/Makefile
libotr.pc
AC_OUTPUT([Makefile src/Makefile toolkit/Makefile tests/Makefile tests/utils/Makefile libotr.pc
tests/utils/tap/Makefile
tests/unit/Makefile
tests/regression/Makefile
tests/regression/client/Makefile
])
AC_OUTPUT
SUBDIRS = utils unit regression
AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src -I$(top_srcdir)/tests/utils/ -I$(srcdir)
LIBTAP=$(top_builddir)/tests/utils/tap/libtap.la
check-am:
./run.sh test_list
dist_noinst_SCRIPTS = test_list run.sh
EXTRA_DIST = run.sh test_list
SUBDIRS = client
EXTRA_DIST = random-msg.sh random-msg-disconnect.sh random-msg-disconnect-auth.sh \
random-msg-disconnect-frag-auth.sh random-msg-fast.sh random-msg-auth.sh \
random-msg-disconnect-frag.sh random-msg-frag.sh
AM_CFLAGS = -I$(top_srcdir)/include \
-I$(top_srcdir)/src \
-I$(top_srcdir)/tests/utils/ \
-I$(srcdir)
LIBTAP=$(top_builddir)/tests/utils/tap/libtap.la
LIBOTR=$(top_builddir)/src/libotr.la
noinst_PROGRAMS = client
client_SOURCES = client.c
client_LDADD = $(LIBTAP) $(LIBOTR) -lpthread @LIBGCRYPT_LIBS@
EXTRA_DIST = otr.key
This diff is collapsed.
(privkeys
(account
(name alice)
(protocol otr-test)
(private-key
(dsa
(p #00E4240AE9740D5FB1DF076A3270143BBD5B66DEB9BFD601CF3C3DC3E8D76BF1EA0D1A66E209516600E915B79552887EE9810D613C63EA6D2B6E69321C3C81F71F533F02430D20AF65C05C15BA46EF10C78EFF3BE687C33A4F6EA90877AB30E6423070AAFD3F22B5939D0DC8FBE5145A68F38EBA98ADCA7E06EFBC5E345E9AEDEF#)
(q "\x00ջ*i#bU~{Uq")
(g #00D3A15721AEF3A49DF26E875EC8C5FF4096B0B1717AF89485A015245176FD4AE3065D9F7B2D185B1E02CEAFB53E6984B1D341E62EBB4A5C189EB40959CFED0C48DAE73F3391C5E1482372E9DE539CD6911C54583DC0A3179547A38E19549F81A6DBFA8036C471C2A358D4B3AB86C7424556DFD61C35CC1EC08304B0102A0EEE08#)
(y #6E3996E07B6CB54DC443BD83033293956E5B7CCC511D19DCAC8735496B061D6EB6DF3D5540548D3C97201393E669EF9066BCA6A72E3AC68710188BEDF06FDF22548D8709BD4E9E1AD02DB0E193399BEB39DE5218D70C999D9856D3205DB79BA8DFC188726E646A1BE1722843F5E56A51C499C5BE5F63FACE7802ECD565E99F39#)
(x #2C5887BA7EC5F426B6BE4438E2FAE4589DBF2CB6#)
)
)
)
(account
(name bob)
(protocol otr-test)
(private-key
(dsa
(p #00BD114F05B275A8A94954047983C5CD96ED95C782D2ED65A18E78C98E8EAFBAF58BBD046BE9895AD55FD0FF95907E7EBD6ACA2688D24779BDE9F0AAB13924CE65F597F9C9B9953DDBACF51DA7113FBAB9BE1DF6C6EA836DEB48983CCDCFC4125B5013D0CE52F890D0C391A035D30BCD5169A3451FD7023685274576DCB5F8FA47#)
(q #00D1DA3915346A704EB2D2F2A48CD48F3DCC4CF25D#)
(g #501BCFB989AD2C346BBD7782CA0230551F976B1A07EE3AEE27E4B63B7B00B1ACA712AD85784986411278163156D4DBA9DF75C8560F9C2E02C02AEC830EC403A56B6F64432869D6CA9314A648076511343507629BF4FC96F8FDBB9797258DDF11F437B1450BA23F1AA7E885EC6A33D37B7D7EC384A004420DB238E140B94AAAFE#)
(y #7C9CB7732164787DD1931BB58257665EB60D6AA72B8D64D634530A61BE93D5AF01427962646542F18401B73032B12B9CBCAE8E3CF080DAD55C6612A97D6D8776CF2CBDD3AAC75D302B60E6956E5B3C60B39E171A2D5F150A924C6E22981EFDF052D5C6507B2DEC15E96CB6CAF7B260D5386BBDD7D7F69B4BF14451D64D847AEB#)
(x #00AB1E941176D94505911118AC799A504ADCCE88F8#)
)
)
)
(account
(name otrtest3)
(protocol otr-test)
(private-key
(dsa
(p #00BB4C57669E50E4C35F8E4CA84855CF2C83EE75C4F44B4BB4A7E88590D394D7A738E82EE97892E5051CE45E200741E18D423137AA8E6679B1CFAB4FF11D45D8C9CBDE388D30FC800B4879713E3C57BA48A92FE135BB9AF265F770B706FB9A04802244D12CBFFD97ACE5C73FCE88C2B716B4B22B994CD6429A7E16D9B6D1874137#)
(q #00C40DA63B679A80FC31BF49A68503BB39754D0A45#)
(g #6C0A48BEA859587D6677306D1777A2A0635470F149A86EB64EA62EAAA4C21ECE4375ACD016B776E3AD3411C18BB3FF37F963FCEBB8820FF8838AFA6FCD1B39558DAB78450AE2ED9457DEDBDCE13DF5A6B20A738D2973D375D360C044AF7F0204CCC372098F0B6460963274B1EA0B5FEC93571A15F5C03DCDF54EE83BB198F363#)
(y #00AB2C8A82F020DB99EF5B7A8330EC43E0D5EBD623FEB67D1B046D88FACA01D8E31E4D7865DC62D4DA58CF8BC7FF4B57C203A9F7F5C85DAB1B63D63299EF13AD89AAA7E6638C9DBC42D096408936C9F0382224CFB5C1528DCC8C7F2554CB4CA2FF3C3239BC921F1C690295DD9AE69C8EF5BBD8E58A8FAA8BB9D5F88463CAECEE7B#)
(x #7824B713A4E5FA6D6C69172196648CD4657A1ED1#)
)
)
)
)
#!/bin/bash
CURDIR=$(dirname $0)/
TESTDIR=$CURDIR/..
CLIENT=$CURDIR/client/client
KEYFILE=$CURDIR/client/otr.key
MAX_MSG=50
MAX_INTERVAL=500 # msec
source $TESTDIR/utils/tap/tap.sh
diag "Messaging with random interval of max $MAX_INTERVAL and authentication"
$CLIENT --load-key $KEYFILE --timeout $MAX_INTERVAL --max-msg $MAX_MSG --auth
#!/bin/bash
CURDIR=$(dirname $0)/
TESTDIR=$CURDIR/..
CLIENT=$CURDIR/client/client
KEYFILE=$CURDIR/client/otr.key
MAX_MSG=50
MAX_INTERVAL=100 # msec
source $TESTDIR/utils/tap/tap.sh
diag "Messaging with random interval of max $MAX_INTERVAL with disconnect and authentication"
$CLIENT --disconnect --load-key $KEYFILE --timeout $MAX_INTERVAL --max-msg $MAX_MSG --auth
#!/bin/bash
CURDIR=$(dirname $0)/
TESTDIR=$CURDIR/..
CLIENT=$CURDIR/client/client
KEYFILE=$CURDIR/client/otr.key
MAX_MSG=20
MAX_INTERVAL=500 # msec
source $TESTDIR/utils/tap/tap.sh
diag "Messaging with random interval of max $MAX_INTERVAL with disconnect, framgents and authentication"
$CLIENT --load-key $KEYFILE --timeout $MAX_INTERVAL --max-msg $MAX_MSG --fragment --disconnect --auth
#!/bin/bash
CURDIR=$(dirname $0)/
TESTDIR=$CURDIR/..
CLIENT=$CURDIR/client/client
KEYFILE=$CURDIR/client/otr.key
MAX_MSG=20
MAX_INTERVAL=500 # msec
source $TESTDIR/utils/tap/tap.sh
diag "Messaging with random interval of max $MAX_INTERVAL, disconnect and fragmentation"
$CLIENT --load-key $KEYFILE --timeout $MAX_INTERVAL --max-msg $MAX_MSG --fragment --disconnect
#!/bin/bash
CURDIR=$(dirname $0)/
TESTDIR=$CURDIR/..
CLIENT=$CURDIR/client/client
KEYFILE=$CURDIR/client/otr.key
MAX_MSG=50
MAX_INTERVAL=500 # msec
source $TESTDIR/utils/tap/tap.sh
diag "Messaging with random interval of max $MAX_INTERVAL with disconnect"
$CLIENT --disconnect --load-key $KEYFILE --timeout $MAX_INTERVAL --max-msg $MAX_MSG
#!/bin/bash
CURDIR=$(dirname $0)/
TESTDIR=$CURDIR/..
CLIENT=$CURDIR/client/client
KEYFILE=$CURDIR/client/otr.key
MAX_MSG=250
MAX_INTERVAL=10 # msec
source $TESTDIR/utils/tap/tap.sh
diag "Messaging with random interval of max $MAX_INTERVAL and number of message to $MAX_MSG"
$CLIENT --load-key $KEYFILE --timeout $MAX_INTERVAL --max-msg $MAX_MSG
#!/bin/bash
CURDIR=$(dirname $0)/
TESTDIR=$CURDIR/..
CLIENT=$CURDIR/client/client
KEYFILE=$CURDIR/client/otr.key
MAX_MSG=20
MAX_INTERVAL=500 # msec
source $TESTDIR/utils/tap/tap.sh
diag "Messaging with random interval of max $MAX_INTERVAL and fragmentation"
$CLIENT --load-key $KEYFILE --timeout $MAX_INTERVAL --max-msg $MAX_MSG --fragment
#!/bin/bash
CURDIR=$(dirname $0)/
TESTDIR=$CURDIR/..
CLIENT=$CURDIR/client/client
KEYFILE=$CURDIR/client/otr.key
MAX_MSG=50
MAX_INTERVAL=500 # msec
source $TESTDIR/utils/tap/tap.sh
diag "Messaging with random interval of max $MAX_INTERVAL"
$CLIENT --load-key $KEYFILE --timeout $MAX_INTERVAL --max-msg $MAX_MSG
#!/bin/bash
#
# Copyright (C) 2013 - Christian Babeux <christian.babeux@efficios.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
[ -z "$1" ] && echo "Error: No testlist. Please specify a testlist to run." && exit 1
prove $2 --merge --exec '' - < $1
unit/test_auth
unit/test_proto
unit/test_dh
unit/test_b64
unit/test_context
unit/test_userstate
unit/test_tlv
unit/test_mem
unit/test_sm
unit/test_instag
unit/test_privkey
regression/random-msg.sh
regression/random-msg-auth.sh
regression/random-msg-fast.sh
regression/random-msg-frag.sh
regression/random-msg-disconnect.sh
regression/random-msg-disconnect-frag.sh
regression/random-msg-disconnect-auth.sh
regression/random-msg-disconnect-frag-auth.sh
AM_CFLAGS = -I$(top_srcdir)/include \
-I$(top_srcdir)/src \
-I$(top_srcdir)/tests/utils/ \
-I$(srcdir)
LIBTAP=$(top_builddir)/tests/utils/tap/libtap.la
LIBOTR=$(top_builddir)/src/libotr.la
noinst_PROGRAMS = test_auth test_proto test_dh \
test_b64 test_context \
test_userstate test_tlv \
test_mem test_sm test_instag \
test_privkey
test_auth_SOURCES = test_auth.c
test_auth_LDADD = $(LIBTAP) $(LIBOTR) @LIBGCRYPT_LIBS@
test_proto_SOURCES = test_proto.c
test_proto_LDADD = $(LIBTAP) $(LIBOTR) @LIBGCRYPT_LIBS@
test_dh_SOURCES = test_dh.c
test_dh_LDADD = $(LIBTAP) $(LIBOTR) @LIBGCRYPT_LIBS@
test_b64_SOURCES = test_b64.c
test_b64_LDADD = $(LIBTAP) $(LIBOTR) @LIBGCRYPT_LIBS@
test_context_SOURCES = test_context.c
test_context_LDADD = $(LIBTAP) $(LIBOTR) @LIBGCRYPT_LIBS@
test_userstate_SOURCES = test_userstate.c
test_userstate_LDADD = $(LIBTAP) $(LIBOTR) @LIBGCRYPT_LIBS@
test_tlv_SOURCES = test_tlv.c
test_tlv_LDADD = $(LIBTAP) $(LIBOTR) @LIBGCRYPT_LIBS@
test_mem_SOURCES = test_mem.c
test_mem_LDADD = $(LIBTAP) $(LIBOTR) @LIBGCRYPT_LIBS@
test_sm_SOURCES = test_sm.c
test_sm_LDADD = $(LIBTAP) $(LIBOTR) @LIBGCRYPT_LIBS@
test_instag_SOURCES = test_instag.c
test_instag_LDADD = $(LIBTAP) $(LIBOTR) @LIBGCRYPT_LIBS@
test_privkey_SOURCES = test_privkey.c
test_privkey_LDADD = $(LIBTAP) $(LIBOTR) @LIBGCRYPT_LIBS@
EXTRA_DIST = instag.txt
alice_xmpp XMPP 01234567
alice_irc IRC 9abcdef0
alice_inv IRC WRONG
alice_icq ICQ 98765432
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment