forked from Mirrors/sngrep
Add basic Testing files
This commit is contained in:
parent
d8ab9f3032
commit
297ece114a
|
@ -4,8 +4,11 @@
|
|||
|
||||
# Build files
|
||||
src/sngrep
|
||||
src/*.o
|
||||
src/.deps
|
||||
tests/test-*.log
|
||||
tests/test-*.trs
|
||||
tests/test-???
|
||||
*/*.o
|
||||
*/.deps
|
||||
src/config.h*
|
||||
src/stamp-h1
|
||||
|
||||
|
@ -22,6 +25,7 @@ configure
|
|||
missing
|
||||
install-sh
|
||||
depcomp
|
||||
test-driver
|
||||
|
||||
# Ignore Doxygen generated files
|
||||
doc/html
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
SUBDIRS=src config doc
|
||||
SUBDIRS=src config doc tests
|
||||
EXTRA_DIST=bootstrap.sh
|
||||
|
|
|
@ -198,4 +198,5 @@ AC_CONFIG_FILES([Makefile])
|
|||
AC_CONFIG_FILES([src/Makefile])
|
||||
AC_CONFIG_FILES([config/Makefile])
|
||||
AC_CONFIG_FILES([doc/Makefile])
|
||||
AC_CONFIG_FILES([tests/Makefile])
|
||||
AC_OUTPUT
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
check_PROGRAMS=test-001 test-002 test-003 test-004 test-005 test-006 test-007
|
||||
test_001_SOURCES=test_001.c
|
||||
test_002_SOURCES=test_002.c
|
||||
test_003_SOURCES=test_003.c
|
||||
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
|
||||
|
||||
TESTS = $(check_PROGRAMS)
|
|
@ -0,0 +1,16 @@
|
|||
Basic testing programs for sngrep.
|
||||
|
||||
This set of test will do some basic inputs to check sngrep screen navigation
|
||||
doesn't crash. This checks are ultra-super-basic.
|
||||
|
||||
- test_001 : UI testing
|
||||
- test_002 : Call List testing
|
||||
- test_003 : Call Flow testing
|
||||
- test_004 : Call Raw testing
|
||||
- test_005 : Column selection testing
|
||||
- test_006 : Message diff testing
|
||||
- test_007: Test vector container structures
|
||||
|
||||
Sample capture files has been taken from wireshark Wiki:
|
||||
- https://wiki.wireshark.org/SampleCaptures
|
||||
|
Binary file not shown.
|
@ -0,0 +1,36 @@
|
|||
/**************************************************************************
|
||||
**
|
||||
** sngrep - SIP Messages flow viewer
|
||||
**
|
||||
** Copyright (C) 2015 Ivan Alonso (Kaian)
|
||||
** Copyright (C) 2015 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>
|
||||
*
|
||||
* Basic read from file test
|
||||
*/
|
||||
|
||||
const char keys[] =
|
||||
{
|
||||
27,
|
||||
10,
|
||||
0
|
||||
};
|
||||
|
||||
#include "test_input.c"
|
|
@ -0,0 +1,66 @@
|
|||
/**************************************************************************
|
||||
**
|
||||
** sngrep - SIP Messages flow viewer
|
||||
**
|
||||
** Copyright (C) 2015 Ivan Alonso (Kaian)
|
||||
** Copyright (C) 2015 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_002.c
|
||||
* @author Ivan Alonso [aka Kaian] <kaian@irontec.com>
|
||||
*
|
||||
* Basic Call list testing
|
||||
*/
|
||||
|
||||
const char keys[] =
|
||||
{
|
||||
/* Swap some options */
|
||||
'c', 'l', 'p', 'p',
|
||||
/* Select some dialogs */
|
||||
107, 32, 107, 107, 32, 107, 107, 107, 32, 107, 107,
|
||||
/* Enter Call Flow */
|
||||
10, 27,
|
||||
/* Enter Call Raw */
|
||||
'R', 27,
|
||||
/* Enter Filter screen */
|
||||
'F', 27,
|
||||
/* Enter Column screen */
|
||||
't', 27,
|
||||
/* Unselect some dialogs */
|
||||
32, 107, 32,
|
||||
/* Move beyond list limits */
|
||||
107, 107, 107, 107, 107, 106,
|
||||
107, 107, 107, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106,
|
||||
4, 4, 2, 2, 4, 2, 4, 2,
|
||||
/* Enter help screen */
|
||||
'h', 100,
|
||||
/* Enter save screen */
|
||||
's', 20, 30, 40, 50, 27,
|
||||
/* Enter display filter */
|
||||
'/', 20, 30, 40, 40, 10,
|
||||
'/', 27,
|
||||
/* Enter Call Flow once again */
|
||||
10, 27,
|
||||
/* Exit */
|
||||
27,
|
||||
10,
|
||||
0
|
||||
};
|
||||
|
||||
#include "test_input.c"
|
|
@ -0,0 +1,74 @@
|
|||
/**************************************************************************
|
||||
**
|
||||
** sngrep - SIP Messages flow viewer
|
||||
**
|
||||
** Copyright (C) 2015 Ivan Alonso (Kaian)
|
||||
** Copyright (C) 2015 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_003.c
|
||||
* @author Ivan Alonso [aka Kaian] <kaian@irontec.com>
|
||||
*
|
||||
* Basic Call Flow testing
|
||||
*/
|
||||
|
||||
const char keys[] =
|
||||
{
|
||||
/* Select some dialogs */
|
||||
32, 107, 32, 107,
|
||||
/* Enter Call Flow */
|
||||
10, 27,
|
||||
/* Move arrow messages */
|
||||
107, 107, 107, 107, 107, 106,
|
||||
107, 107, 107, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106,
|
||||
4, 4, 2, 2, 4, 2, 4, 2,
|
||||
/* Reenter Call Flow */
|
||||
10,
|
||||
/* Swap colors */
|
||||
'c', 'c', 'c', 'c', 'c', 'c',
|
||||
/* Enter Extended Call Flow */
|
||||
'x', 'x', 'x', 'x',
|
||||
/* Compress column display */
|
||||
's',
|
||||
/* Toggle media display */
|
||||
'd', 'd', 'd', 'd', 'd',
|
||||
/* Toggle Only SDP */
|
||||
'D',
|
||||
/* Enter Call Raw (all dialogs) */
|
||||
'R', 27,
|
||||
/* Enter Call Raw (single message) */
|
||||
10, 27,
|
||||
/* Enter help screen */
|
||||
'h', 100,
|
||||
/* Toggle raw screen */
|
||||
't', 't', 't', 't',
|
||||
/* Change Raw size */
|
||||
'0', '0', '0', '0', '0', '0', '0', '0',
|
||||
'9', '9', '9', '9', '9', '9', '9', '9',
|
||||
/* Reset Raw size */
|
||||
'T', 'T',
|
||||
/* Leave Call Flow */
|
||||
27,
|
||||
/* Exit */
|
||||
27,
|
||||
10,
|
||||
0
|
||||
};
|
||||
|
||||
#include "test_input.c"
|
|
@ -0,0 +1,65 @@
|
|||
/**************************************************************************
|
||||
**
|
||||
** sngrep - SIP Messages flow viewer
|
||||
**
|
||||
** Copyright (C) 2015 Ivan Alonso (Kaian)
|
||||
** Copyright (C) 2015 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_004.c
|
||||
* @author Ivan Alonso [aka Kaian] <kaian@irontec.com>
|
||||
*
|
||||
* Basic Call Raw testing
|
||||
*/
|
||||
const int keys[] =
|
||||
{
|
||||
/* Select some dialogs */
|
||||
32, 107, 107, 107, 32, 107,
|
||||
/* Show Raw panel */
|
||||
'r',
|
||||
/* Cicle options */
|
||||
'c', 'c', 'c', 'c', 'c', 'c',
|
||||
'a', 'a', 'a', 'a', 'a', 'a',
|
||||
'l', 'l', 'l', 'C', 'C', 'C',
|
||||
/* Move through Raw panel */
|
||||
107, 107, 107, 107, 107, 106,
|
||||
107, 107, 107, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106,
|
||||
4, 4, 2, 2, 4, 2, 4, 2,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
/* Enter save screen */
|
||||
's', 20, 30, 40, 50, 60, 27,
|
||||
/* Leave call Raw */
|
||||
27,
|
||||
/* Exit */
|
||||
27,
|
||||
10,
|
||||
0
|
||||
};
|
||||
|
||||
#include "test_input.c"
|
|
@ -0,0 +1,63 @@
|
|||
/**************************************************************************
|
||||
**
|
||||
** sngrep - SIP Messages flow viewer
|
||||
**
|
||||
** Copyright (C) 2015 Ivan Alonso (Kaian)
|
||||
** Copyright (C) 2015 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_005.c
|
||||
* @author Ivan Alonso [aka Kaian] <kaian@irontec.com>
|
||||
*
|
||||
* Basic Column selection testing
|
||||
*/
|
||||
|
||||
const int keys[] =
|
||||
{
|
||||
/* Show Raw panel */
|
||||
't',
|
||||
/* Cycle through fields */
|
||||
9, 9, 9, 9, 9, 9,
|
||||
9, 107, 107, 9, 106,
|
||||
/* Move through Column list */
|
||||
107, 107, 107, 107, 107, 106,
|
||||
107, 107, 107, 107, 107, 107,
|
||||
107, 107, 107, 107, 107, 107,
|
||||
107, 107, 107, 107, 107, 107,
|
||||
107, 107, 107, 107, 107, 107,
|
||||
107, 107, 107, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106,
|
||||
106, 106, 106, 106, 106, 106,
|
||||
/* Move items up and down */
|
||||
'-', '-', '-', '-',
|
||||
107, 107,
|
||||
'+', '+', '+', '+',
|
||||
107, 107,
|
||||
'-', '-', '-', '-',
|
||||
/* Apply new settings */
|
||||
10,
|
||||
/* Exit */
|
||||
27,
|
||||
10,
|
||||
0
|
||||
};
|
||||
|
||||
#include "test_input.c"
|
|
@ -0,0 +1,43 @@
|
|||
/**************************************************************************
|
||||
**
|
||||
** sngrep - SIP Messages flow viewer
|
||||
**
|
||||
** Copyright (C) 2015 Ivan Alonso (Kaian)
|
||||
** Copyright (C) 2015 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_006.c
|
||||
* @author Ivan Alonso [aka Kaian] <kaian@irontec.com>
|
||||
*
|
||||
* Basic Message diff testing
|
||||
*/
|
||||
const int keys[] =
|
||||
{
|
||||
/* Select some dialog */
|
||||
107, 107, 107, 32, 10,
|
||||
/* Move Select some messages */
|
||||
107, 107, 32, 32, 107, 32,
|
||||
107, 107, 107, 106, 32,
|
||||
/* Leave Diff screen */
|
||||
27, 27,
|
||||
/* Exit */
|
||||
27,
|
||||
10,
|
||||
0
|
||||
};
|
||||
|
||||
#include "test_input.c"
|
|
@ -0,0 +1,79 @@
|
|||
/**************************************************************************
|
||||
**
|
||||
** sngrep - SIP Messages flow viewer
|
||||
**
|
||||
** Copyright (C) 2015 Ivan Alonso (Kaian)
|
||||
** Copyright (C) 2015 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_vector.c
|
||||
* @author Ivan Alonso [aka Kaian] <kaian@irontec.com>
|
||||
*
|
||||
* Basic testing of vector structures
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include "vector.h"
|
||||
|
||||
int main ()
|
||||
{
|
||||
vector_t *vector;
|
||||
|
||||
// Basic Vector append/remove test
|
||||
vector = vector_create(10, 10);
|
||||
assert(vector);
|
||||
assert(vector_count(vector) == 0);
|
||||
vector_append(vector, 0);
|
||||
assert(vector_count(vector) == 0);
|
||||
vector_append(vector, malloc(1024));
|
||||
assert(vector_count(vector) == 1);
|
||||
assert(vector_first(vector) == vector_item(vector, 0));
|
||||
vector_remove(vector, vector_first(vector));
|
||||
assert(vector_count(vector) == 0);
|
||||
assert(vector_first(vector) == vector_item(vector, 0));
|
||||
|
||||
// Vector overflow test
|
||||
vector_append(vector, malloc(32));
|
||||
vector_append(vector, malloc(32));
|
||||
vector_append(vector, malloc(32));
|
||||
vector_append(vector, malloc(32));
|
||||
vector_append(vector, malloc(32));
|
||||
vector_append(vector, malloc(32));
|
||||
vector_append(vector, malloc(32));
|
||||
vector_append(vector, malloc(32));
|
||||
vector_append(vector, malloc(32));
|
||||
vector_append(vector, malloc(32));
|
||||
// Next append requires memory reallocation
|
||||
vector_append(vector, malloc(32));
|
||||
vector_append(vector, malloc(32));
|
||||
vector_append(vector, malloc(32));
|
||||
vector_append(vector, malloc(32));
|
||||
vector_append(vector, malloc(32));
|
||||
vector_append(vector, malloc(32));
|
||||
// Expected vector size
|
||||
assert(vector_count(vector) == 16);
|
||||
// Expected empty position
|
||||
assert(vector_item(vector, vector_count(vector)) == 0);
|
||||
// Remove position (use generic destroyer)
|
||||
vector_set_destroyer(vector, vector_generic_destroyer);
|
||||
vector_remove(vector, vector_item(vector, 12));
|
||||
assert(vector_count(vector) == 15);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/**************************************************************************
|
||||
**
|
||||
** sngrep - SIP Messages flow viewer
|
||||
**
|
||||
** Copyright (C) 2015 Ivan Alonso (Kaian)
|
||||
** Copyright (C) 2015 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_input.c
|
||||
* @author Ivan Alonso [aka Kaian] <kaian@irontec.com>
|
||||
*
|
||||
* Basic input injector for sngrep testing
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#ifndef TEST_MAX_DURATION
|
||||
#define TEST_MAX_DURATION 5
|
||||
#endif
|
||||
|
||||
#ifndef TEST_INITIAL_WAIT
|
||||
#define TEST_INITIAL_WAIT 1000 * 600
|
||||
#endif
|
||||
|
||||
#ifndef TEST_KEY_DELAY
|
||||
#define TEST_KEY_DELAY 1000
|
||||
#endif
|
||||
|
||||
#ifndef TEST_PCAP_INPUT
|
||||
#define TEST_PCAP_INPUT "aaa.pcap"
|
||||
#endif
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
int ppipe[2];
|
||||
int unused, ret;
|
||||
unused = pipe(ppipe);
|
||||
|
||||
// Max test duration
|
||||
alarm(TEST_MAX_DURATION);
|
||||
|
||||
if (!fork()) {
|
||||
char *argv[] =
|
||||
{
|
||||
"../src/sngrep",
|
||||
"-I",
|
||||
TEST_PCAP_INPUT,
|
||||
0 };
|
||||
dup2(ppipe[0], STDIN_FILENO);
|
||||
execv(argv[0], argv);
|
||||
} else {
|
||||
usleep(TEST_INITIAL_WAIT);
|
||||
int i;
|
||||
for (i = 0; keys[i]; i++) {
|
||||
unused = write(ppipe[1], &keys[i], sizeof(char));
|
||||
usleep(TEST_KEY_DELAY);
|
||||
}
|
||||
unused = wait(&ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
Loading…
Reference in New Issue