blob: 88a78a88e044f5456d7245e651f756d8e21ea03c [file] [log] [blame]
Harald Welte3a194402017-07-22 17:07:51 +02001module Test {
2
3 import from BSSGP_Helper_Functions all;
4 import from BSSGP_Types all;
5
6 type component dummy_CT {
7 }
8
9 function f_assert_prepr(in octetstring a, in octetstring b) {
10 log ("Input: ", a);
11 log ("Expected: ", b);
12 var octetstring a_preprocessed := f_BSSGP_preprocess_pdu(a);
13 log ("Preprocessed: ", a_preprocessed);
14
15 if (a_preprocessed != b) {
16 setverdict(fail);
17 } else {
18 setverdict(pass);
19 }
20 }
21
22 function f_dec_and_log(in octetstring inp) {
23 log("Input: ", inp);
24 var octetstring inp_p := f_BSSGP_preprocess_pdu(inp);
25 log ("Preprocessed: ", inp_p);
26 var BssgpPdu dec := dec_BssgpPdu(inp_p);
27 log("Decoded: ", dec);
28 }
29
30 testcase TC_selftest() runs on dummy_CT {
31 const octetstring c_bvc_reset_pcu := '2204820000078108088832f44000c80051e0'O;
32 const octetstring c_bvc_reset_q := '2204820000078100'O;
33 const octetstring c_status_pcu := '4107810515882204820000078103'O;
34 const octetstring c_reset_ack_q := '2304820000'O;
35 const octetstring c_reset_ack_pcu := '23048200c4'O;
36 const octetstring c_unblock_pcu := '24048200c4'O;
37 const octetstring c_unblock_ack_q := '25048200c4'O;
38 const octetstring c_fc_bvc_pcu := '261e8101058200fa038200c8018200fa1c8200c806820000'O;
39 const octetstring c_fc_bvc_ack_q := '271e8101'O;
40 const octetstring c_gmm_mo_att_req := '01bb146ddd000004088832f44000c80051e000800e003b01c001080103e5e000110a0005f4fb146ddd32f44000c8001d1b53432b37159ef9090070000dd9c6321200e00019b32c642401c0002017057bf0ec'O;
41 const octetstring c_gmm_mt_ac_req := '00bb146ddd0050001682ffff0a8204030e9c41c001081200102198c72477ea104895e8b959acc58b108182f4d045'O;
42 const octetstring c_gmm_mo_ac_resp := '01bb146ddd000004088832f44000c80051e000800e000e01c00508130122fa361f5fdd623d'O;
43 const octetstring c_gmm_mt_att_acc := '00bb146ddd0050001682ffff0a8204030e9841c005080201340432f44000c8001805f4fb146ddd0967d0'O;
44 const octetstring c_gmm_mt_det_req := '00bb146ddd0050001682ffff0a8204030e8941c00908050215f0b6'O;
45 const octetstring c_gmm_mo_att_cpl := '01fb146ddd000004088832f44000c80051e000800e000801c009080339d7bc'O;
46
47 /* single byte length to two byte length */
48 f_assert_prepr('04058101'O, '0405000101'O);
49 f_assert_prepr('040589000102030405060708'O, '04050009000102030405060708'O);
50 /* two byte length to two byte length */
51 f_assert_prepr('0405000101'O, '0405000101'O);
52 /* special case: DL-UD + UL-UD */
53 f_assert_prepr('00aabbccddeeffaa29822342'O, '00aabbccddeeffaa2900022342'O);
54 f_assert_prepr('01aabbccddeeffaa29822342'O, '01aabbccddeeffaa2900022342'O);
55 /* multiple TLVs */
56 f_assert_prepr('234281aa4382bbbb'O, '23420001aa430002bbbb'O);
57 f_assert_prepr('230080'O, '23000000'O);
58
59 f_dec_and_log(c_bvc_reset_pcu);
60 f_dec_and_log(c_bvc_reset_q);
61 f_dec_and_log(c_status_pcu);
62 f_dec_and_log(c_reset_ack_q);
63 f_dec_and_log(c_reset_ack_pcu);
64 f_dec_and_log(c_unblock_pcu);
65 f_dec_and_log(c_unblock_ack_q);
66 f_dec_and_log(c_fc_bvc_pcu);
67 f_dec_and_log(c_fc_bvc_ack_q);
68 f_dec_and_log(c_gmm_mo_att_req);
69 f_dec_and_log(c_gmm_mt_ac_req);
70 f_dec_and_log(c_gmm_mo_ac_resp);
71 f_dec_and_log(c_gmm_mt_att_acc);
72 f_dec_and_log(c_gmm_mt_det_req);
73 f_dec_and_log(c_gmm_mo_att_cpl);
74 }
75
76 control {
77 execute(TC_selftest());
78 }
79};