blob: c99766a72e5253bac430cbcee561927d8ea62b84 [file] [log] [blame]
Holger Freytheraa0fb362008-12-28 21:55:40 +00001/* simple test for the gsm0408 formatting functions */
2/*
3 * (C) 2008 by Holger Hans Peter Freyther <zecke@selfish.org>
4 * All Rights Reserved
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 */
21
22#include <assert.h>
23#include <stdio.h>
24#include <stdlib.h>
25
26#include <openbsc/gsm_04_08.h>
27
28#define COMPARE(result, op, value) \
29 if (!((result) op (value))) {\
30 fprintf(stderr, "Compare failed. Was %x should be %x in %s:%d\n",result, value, __FILE__, __LINE__); \
31 exit(-1); \
32 }
33
34
35/*
36 * Test Location Area Identifier formatting. Table 10.5.3 of 04.08
37 */
38static void test_location_area_identifier(void)
39{
40 struct gsm48_loc_area_id lai48;
41
42 printf("Testing test location area identifier\n");
43
44 /*
45 * Test the default/test setup. Coming from
46 * bsc_hack.c dumps
47 */
48 gsm0408_generate_lai(&lai48, 1, 1, 1);
49 COMPARE(lai48.digits[0], ==, 0x00);
50 COMPARE(lai48.digits[1], ==, 0xF1);
51 COMPARE(lai48.digits[2], ==, 0x10);
52 COMPARE(lai48.lac, ==, htons(0x0001));
53
54 gsm0408_generate_lai(&lai48, 602, 1, 15);
55 COMPARE(lai48.digits[0], ==, 0x06);
56 COMPARE(lai48.digits[1], ==, 0xF2);
57 COMPARE(lai48.digits[2], ==, 0x10);
58 COMPARE(lai48.lac, ==, htons(0x000f));
59}
60
61int main(int argc, char** argv)
62{
63 test_location_area_identifier();
64}
65
66
67
68/*
69 * Stubs to compile and link
70 */
Holger Freyther3281f6e2009-02-20 18:33:00 +000071void input_event(void) {}
72void nm_state_event(void) {}