summaryrefslogtreecommitdiffstats
path: root/testsuites/fstests/fsscandir01/init.c
blob: e92d2feceb6a3af40009c0213d1efa0a464bbde9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
 *  COPYRIGHT (c) 2015.
 *  On-Line Applications Research Corporation (OAR).
 *  
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.org/license/LICENSE.
 */

#ifdef HAVE_CONFIG_H
  #include "config.h"
#endif

#include "fstest.h"
#include "fs_config.h"
#include "fstest_support.h"
#include "pmacros.h"

#include <dirent.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <limits.h>

const char rtems_test_name[] = "FSSCANDIR " FILESYSTEM;

/*
 * This code is from the scandir() man page.
 */
static void test_scandir(void)
{
  struct dirent **namelist;
  int n;

  n = scandir(".", &namelist, 0, NULL);
  if (n < 0) {
    perror("scandir");
  } else {
    while(n--) {
      printf("%s\n", namelist[n]->d_name);
      free(namelist[n]);
    }
    free(namelist);
  }

  rtems_test_assert(MAXNAMLEN == NAME_MAX);
}


void test (void)
{
  test_scandir();
}