13 static int test_guess_raw_type(struct isds_ctx
*context
,
14 const struct test
*test
) {
19 isds_raw_type guessed_type
;
23 if (test_mmap_file(test
->file
, &fd
, &buffer
, &length
))
24 FAIL_TEST("Could not load test data from `%s' file", test
->file
);
26 if (test
->error
!= IE_SUCCESS
)
27 /* Do not log expected XML parser failures */
28 isds_set_logging(ILF_XML
, ILL_NONE
);
30 isds_set_logging(ILF_ALL
, ILL_WARNING
);
32 err
= isds_guess_raw_type(context
, &guessed_type
, buffer
, length
);
33 test_munmap_file(fd
, buffer
, length
);
35 if (err
!= test
->error
)
36 FAIL_TEST("Wrong return value: expected=%s, got=%s",
37 isds_strerror(test
->error
), isds_strerror(err
));
39 if (!err
&& guessed_type
!= test
->type
)
40 FAIL_TEST("Wrong raw type guessed on file %s: expected=%d, got=%d",
41 test
->file
, test
->type
, guessed_type
);
48 struct test tests
[] = {
50 .name
= "unsigned incoming message",
51 .file
= SRCDIR
"/server/messages/received_message-151916.xml",
52 .type
= RAWTYPE_INCOMING_MESSAGE
,
56 .name
= "plain signed incoming message",
58 "/server/messages/received_signed_message-330141.xml",
59 .type
= RAWTYPE_PLAIN_SIGNED_INCOMING_MESSAGE
,
63 .name
= "CMS signed incoming message",
64 .file
= SRCDIR
"/server/messages/received_message-330141.zfo",
65 .type
= RAWTYPE_CMS_SIGNED_INCOMING_MESSAGE
,
69 .name
= "plain signed sent message",
70 .file
= SRCDIR
"/server/messages/sent_message-206720.xml",
71 .type
= RAWTYPE_PLAIN_SIGNED_OUTGOING_MESSAGE
,
75 .name
= "CMS signed sent message",
76 .file
= SRCDIR
"/server/messages/signed_sent_message-151874.zfo",
77 .type
= RAWTYPE_CMS_SIGNED_OUTGOING_MESSAGE
,
81 .name
= "unsigned delivery info",
82 .file
= SRCDIR
"/server/messages/delivery_info-316590.xml",
83 .type
= RAWTYPE_DELIVERYINFO
,
87 .name
= "plain signed delivery info",
88 .file
= SRCDIR
"/server/messages/signed_delivered-DD_170272.xml",
89 .type
= RAWTYPE_PLAIN_SIGNED_DELIVERYINFO
,
93 .name
= "CMS signed delivery info",
94 .file
= SRCDIR
"/server/messages/signed_delivered-DD_170272.zfo",
95 .type
= RAWTYPE_CMS_SIGNED_DELIVERYINFO
,
107 struct isds_ctx
*context
= NULL
;
109 INIT_TEST("guess_raw_type");
112 ABORT_UNIT("init_isds() failed");
114 context
= isds_ctx_create();
116 ABORT_UNIT("isds_ctx_create() failed");
118 for (int i
= 0; tests
[i
].name
; i
++)
119 TEST(tests
[i
].name
, test_guess_raw_type
, context
, &tests
[i
]);
121 isds_ctx_free(&context
);