source: rtems/testsuites/fstests/fsscandir01/init.c @ 57a914a3

4.115
Last change on this file since 57a914a3 was 57a914a3, checked in by Joel Sherrill <joel.sherrill@…>, on 03/03/15 at 21:15:00

Add simple test for scandir() on all file systems tested

updates 1394

  • Property mode set to 100644
File size: 939 bytes
Line 
1/*
2 *  COPYRIGHT (c) 2015.
3 *  On-Line Applications Research Corporation (OAR).
4 * 
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.org/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11  #include "config.h"
12#endif
13
14#include "fstest.h"
15#include "fs_config.h"
16#include "fstest_support.h"
17#include "pmacros.h"
18
19#include <dirent.h>
20#include <stdio.h>
21#include <string.h>
22#include <unistd.h>
23#include <errno.h>
24#include <limits.h>
25
26const char rtems_test_name[] = "FSSCANDIR " FILESYSTEM;
27
28/*
29 * This code is from the scandir() man page.
30 */
31static void test_scandir(void)
32{
33  struct dirent **namelist;
34  int n;
35
36  n = scandir(".", &namelist, 0, NULL);
37  if (n < 0) {
38    perror("scandir");
39  } else {
40    while(n--) {
41      printf("%s\n", namelist[n]->d_name);
42      free(namelist[n]);
43    }
44    free(namelist);
45  }
46}
47
48
49void test (void)
50{
51  test_scandir();
52}
Note: See TracBrowser for help on using the repository browser.