Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / native_client / tests / glibc_syscall_wrappers / test_rewind.c
1 /*
2  * Copyright 2010 The Native Client Authors. All rights reserved.
3  * Use of this source code is governed by a BSD-style license that can be
4  * found in the LICENSE file.
5  */
6
7 #include <assert.h>
8 #include <stdio.h>
9 #include <string.h>
10
11 #define BUF_SIZE 64
12
13 int main(int argc, char** argv) {
14   FILE* file;
15   char buf[BUF_SIZE];
16   int res;
17   int y;
18
19   if (2 != argc) {
20     fprintf(stderr, "Usage: sel_ldr test_rewind.nexe "
21             "path/to/test_rewind_data\n");
22     return 1;
23   }
24   file = fopen(argv[1], "r");
25   assert(NULL != file);
26   for (y = 0; y < 8; ++y) {
27     res = fread(buf, 1, BUF_SIZE, file);
28     assert(0 < res);
29     buf[res] = '\0';
30     res = strcmp(buf, "test");
31     assert(0 == res);
32     rewind(file);
33   }
34   return 0;
35 }