source: rtems/testsuites/fstests/fsscandir01/init.c @ 6af2221

5
Last change on this file since 6af2221 was 6af2221, checked in by Sebastian Huber <sebastian.huber@…>, on 01/24/17 at 09:07:57

fsscandir01: Check MAXNAMLEN and NAME_MAX

Update #1394.

  • Property mode set to 100644
File size: 984 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  rtems_test_assert(MAXNAMLEN == NAME_MAX);
48}
49
50
51void test (void)
52{
53  test_scandir();
54}
Note: See TracBrowser for help on using the repository browser.