diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4187fb5..c65b9ed 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,4 +1,6 @@
-check_PROGRAMS=test-001 test-002 test-003 test-004 test-005 test-006 test-007
+check_PROGRAMS=test-001 test-002 test-003 test-004 test-005
+check_PROGRAMS+=test-006 test-007 test-008 test-009
+
test_001_SOURCES=test_001.c
test_002_SOURCES=test_002.c
test_003_SOURCES=test_003.c
@@ -6,5 +8,7 @@ test_004_SOURCES=test_004.c
test_005_SOURCES=test_005.c
test_006_SOURCES=test_006.c
test_007_SOURCES=test_007.c ../src/vector.c ../src/util.c
+test_008_SOURCES=test_008.c
+test_009_SOURCES=test_009.c
TESTS = $(check_PROGRAMS)
diff --git a/tests/test_008.c b/tests/test_008.c
new file mode 100644
index 0000000..4bcecf3
--- /dev/null
+++ b/tests/test_008.c
@@ -0,0 +1,48 @@
+/**************************************************************************
+ **
+ ** sngrep - SIP Messages flow viewer
+ **
+ ** Copyright (C) 2013-2016 Ivan Alonso (Kaian)
+ ** Copyright (C) 2013-2016 Irontec SL. All rights reserved.
+ **
+ ** This program is free software: you can redistribute it and/or modify
+ ** it under the terms of the GNU General Public License as published by
+ ** the Free Software Foundation, either version 3 of the License, or
+ ** (at your option) any later version.
+ **
+ ** This program is distributed in the hope that it will be useful,
+ ** but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ** GNU General Public License for more details.
+ **
+ ** You should have received a copy of the GNU General Public License
+ ** along with this program. If not, see .
+ **
+ ****************************************************************************/
+/**
+ * @file test_001.c
+ * @author Ivan Alonso [aka Kaian]
+ *
+ * Test for sorting columns based on standard attributes
+ */
+
+const char keys[] =
+ {
+ /* show sort menu */
+ 60,
+ /* move arround menu */
+ 107, 107, 106, 106, 106, 107,
+ /* select sort field */
+ 10,
+ /* move arround call list */
+ 107, 107, 106, 106, 106, 107,
+ /* change sort order */
+ 106, 106, 60, 10,
+ /* change sort order */
+ 122, 122,
+ /* Leave */
+ 27, 10,
+ 0
+ };
+
+#include "test_input.c"
diff --git a/tests/test_009.c b/tests/test_009.c
new file mode 100644
index 0000000..f86a1e0
--- /dev/null
+++ b/tests/test_009.c
@@ -0,0 +1,48 @@
+/**************************************************************************
+ **
+ ** sngrep - SIP Messages flow viewer
+ **
+ ** Copyright (C) 2013-2016 Ivan Alonso (Kaian)
+ ** Copyright (C) 2013-2016 Irontec SL. All rights reserved.
+ **
+ ** This program is free software: you can redistribute it and/or modify
+ ** it under the terms of the GNU General Public License as published by
+ ** the Free Software Foundation, either version 3 of the License, or
+ ** (at your option) any later version.
+ **
+ ** This program is distributed in the hope that it will be useful,
+ ** but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ ** GNU General Public License for more details.
+ **
+ ** You should have received a copy of the GNU General Public License
+ ** along with this program. If not, see .
+ **
+ ****************************************************************************/
+/**
+ * @file test_001.c
+ * @author Ivan Alonso [aka Kaian]
+ *
+ * Test for adding a new attribute column and sorting using it.
+ */
+
+const char keys[] =
+ {
+ /* show sort menu */
+ 60,
+ /* select sort field */
+ 106, 106, 10,
+ /* Enter Column screen */
+ 116, 27,
+ /* add a new column */
+ 106, 106, 106, 32,
+ /* select new sort attribute */
+ 60, 106, 106, 106, 106, 106, 106, 10,
+ /* swap order */
+ 122, 122,
+ /* Leave */
+ 27, 10,
+ 0
+ };
+
+#include "test_input.c"
diff --git a/tests/test_input.c b/tests/test_input.c
index 14b24bb..2140feb 100644
--- a/tests/test_input.c
+++ b/tests/test_input.c
@@ -55,21 +55,22 @@ main()
{
int ppipe[2];
int unused, ret = 0;
+ int child;
unused = pipe(ppipe);
// Max test duration
alarm(TEST_MAX_DURATION);
- if (!fork()) {
- char *argv[] =
- {
- "../src/sngrep",
- "-I",
- TEST_PCAP_INPUT,
- 0 };
+ if ((child = fork()) < 0) {
+ fprintf(stderr, "Fatal: unable to fork test.\n");
+ return 127;
+ } else if (child == 0) {
+ // Child process, run sngrep with test pcap
dup2(ppipe[0], STDIN_FILENO);
+ char *argv[] = { "../src/sngrep", "-I", TEST_PCAP_INPUT, 0 };
execv(argv[0], argv);
} else {
+ // Parent process, send keys to child stdin
usleep(TEST_INITIAL_WAIT);
int i;
for (i = 0; keys[i]; i++) {