test: add tests for column sorting

This commit is contained in:
Kaian 2016-03-01 18:11:22 +01:00
parent 5b1edcf90c
commit 670b87a753
4 changed files with 109 additions and 8 deletions

View File

@ -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)

48
tests/test_008.c Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
**
****************************************************************************/
/**
* @file test_001.c
* @author Ivan Alonso [aka Kaian] <kaian@irontec.com>
*
* 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"

48
tests/test_009.c Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
**
****************************************************************************/
/**
* @file test_001.c
* @author Ivan Alonso [aka Kaian] <kaian@irontec.com>
*
* 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"

View File

@ -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++) {