Treat model numbers 0x4a/0x4d as Silvermont
[platform/upstream/glibc.git] / stdio-common / tst-fmemopen2.c
1 #include <assert.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <sys/types.h>
5
6
7 static int
8 do_test (void)
9 {
10   int result = 0;
11   char buf[100];
12   FILE *fp = fmemopen (buf, sizeof (buf), "w");
13   if (fp == NULL)
14     {
15       puts ("fmemopen failed");
16       return 0;
17     }
18   static const char str[] = "hello world";
19 #define nstr (sizeof (str) - 1)
20   fputs (str, fp);
21   off_t o = ftello (fp);
22   if (o != nstr)
23     {
24       printf ("first ftello returned %jd, expected %zu\n",
25               (intmax_t) o, nstr);
26       result = 1;
27     }
28   rewind (fp);
29   o = ftello (fp);
30   if (o != 0)
31     {
32       printf ("second ftello returned %jd, expected 0\n", (intmax_t) o);
33       result = 1;
34     }
35   if (fseeko (fp, 0, SEEK_END) != 0)
36     {
37       puts ("fseeko failed");
38       return 1;
39     }
40   o = ftello (fp);
41   if (o != nstr)
42     {
43       printf ("third ftello returned %jd, expected %zu\n",
44               (intmax_t) o, nstr);
45       result = 1;
46     }
47   rewind (fp);
48   static const char str2[] = "just hello";
49 #define nstr2 (sizeof (str2) - 1)
50   assert (nstr2 < nstr);
51   fputs (str2, fp);
52   o = ftello (fp);
53   if (o != nstr2)
54     {
55       printf ("fourth ftello returned %jd, expected %zu\n",
56               (intmax_t) o, nstr2);
57       result = 1;
58     }
59   fclose (fp);
60   static const char str3[] = "just hellod";
61   if (strcmp (buf, str3) != 0)
62     {
63       printf ("final string is \"%s\", expected \"%s\"\n",
64               buf, str3);
65       result = 1;
66     }
67   return result;
68 }
69
70 #define TEST_FUNCTION do_test ()
71 #include "../test-skeleton.c"