aboutsummaryrefslogtreecommitdiffstats
path: root/tests/isup/isup_parse_test.c
blob: c6dbdf4eccd4b0407e143ba64b62e3b41ce3caba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * (C) 2010-2011 by Holger Hans Peter Freyther <zecke@selfish.org>
 * (C) 2010-2011 by On-Waves
 * All Rights Reserved
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include <isup_types.h>

#include <stdlib.h>
#include <stdio.h>

#define ASSERT(got,want) \
	if (got != want) { \
		fprintf(stderr, "Values should be the same 0x%x 0x%x at %s:%d\n", \
			got, want, __FILE__, __LINE__); \
		abort(); \
	}

static void test_cic_parsing()
{
	static const uint8_t isup_grs[] = {3, 0, 23, 1, 1, 28};
	struct isup_msg_hdr *hdr;

	hdr = (struct isup_msg_hdr *) isup_grs;
	ASSERT(hdr->cic, 3);
	ASSERT(hdr->msg_type, ISUP_MSG_GRS);
}

static void test_grs_parsing()
{
	static const uint8_t isup_grs[] = {3, 0, 23, 1, 1, 28};
	struct isup_msg_hdr *hdr;
	int range;

	hdr = (struct isup_msg_hdr *) isup_grs;
	range = isup_parse_status(&hdr->data[0], 3);

	ASSERT(range, 28);
}

int main(int argc, char **argv)
{
	test_cic_parsing();
	test_grs_parsing();

	printf("All tests passed.\n");
	return 0;
}

/* stubs */
int mtp_link_set_submit_isup_data() {return -1;}
int mtp_link_set_forward_isup(struct mtp_link_set *s, struct msgb *m, int l) { abort(); }