1 #include <fmtmsg.h>
2 #include <mcheck.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
6 
7 
8 #define MM_TEST 10
9 
10 static int
do_test(void)11 do_test (void)
12 {
13   int result = 0;
14 
15   mtrace ();
16 
17   char TEST[] = "ABCD";
18   if (addseverity (MM_TEST, TEST) != MM_OK)
19     {
20       puts ("addseverity failed");
21       result = 1;
22     }
23   strcpy (TEST, "TEST");
24 
25   if (fmtmsg (MM_PRINT, "GLIBC:tst-fmtmsg", MM_HALT, "halt",
26 	      "should print message for MM_HALT", "GLIBC:tst-fmtmsg:1")
27       != MM_OK)
28     result = 1;
29 
30   if (fmtmsg (MM_PRINT, "GLIBC:tst-fmtmsg", MM_ERROR, "halt",
31 	      "should print message for MM_ERROR", "GLIBC:tst-fmtmsg:2")
32       != MM_OK)
33     result = 1;
34 
35   if (fmtmsg (MM_PRINT, "GLIBC:tst-fmtmsg", MM_WARNING, "halt",
36 	      "should print message for MM_WARNING", "GLIBC:tst-fmtmsg:3")
37       != MM_OK)
38     result = 1;
39 
40   if (fmtmsg (MM_PRINT, "GLIBC:tst-fmtmsg", MM_INFO, "halt",
41 	      "should print message for MM_INFO", "GLIBC:tst-fmtmsg:4")
42       != MM_OK)
43     result = 1;
44 
45   if (fmtmsg (MM_PRINT, "GLIBC:tst-fmtmsg", MM_NOSEV, "halt",
46 	      "should print message for MM_NOSEV", "GLIBC:tst-fmtmsg:5")
47       != MM_OK)
48     result = 1;
49 
50   if (fmtmsg (MM_PRINT, "GLIBC:tst-fmtmsg", MM_TEST, "halt",
51 	      "should print message for MM_TEST", "GLIBC:tst-fmtmsg:6")
52       != MM_OK)
53     result = 1;
54 
55   if (addseverity (MM_TEST, NULL) != MM_OK)
56     {
57       puts ("second addseverity failed");
58       result = 1;
59     }
60 
61   if (addseverity (MM_TEST, NULL) != MM_NOTOK)
62     {
63       puts ("third addseverity unexpectedly succeeded");
64       result = 1;
65     }
66 
67   char *p = strdup ("TEST2");
68   if (addseverity (MM_TEST, p) != MM_OK)
69     {
70       puts ("fourth addseverity failed");
71       result = 1;
72     }
73   if (addseverity (MM_TEST, "TEST3") != MM_OK)
74     {
75       puts ("fifth addseverity failed");
76       result = 1;
77     }
78 
79   free (p);
80 
81   return result;
82 }
83 
84 #define TEST_FUNCTION do_test ()
85 #include "../test-skeleton.c"
86