File indexing completed on 2025-05-11 08:24:37
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 #ifdef HAVE_CONFIG_H
0034 #include "config.h"
0035 #endif
0036
0037
0038 #include <bsp.h> /* for device driver prototypes */
0039 #include "tmacros.h"
0040 #include <rtems.h>
0041 #include <rtems/bspIo.h>
0042 #include <rtems/untar.h>
0043 #include <rtems/error.h>
0044 #include <ftw.h>
0045 #include <dirent.h>
0046 #include <sys/stat.h>
0047 #include <errno.h>
0048 #include <unistd.h>
0049 #include <string.h>
0050 #include <stdio.h>
0051 #include <stdlib.h>
0052 #include <rtems/test.h>
0053
0054 #include "psxftw01-tar.h"
0055 #include "psxftw01-tar-gz.h"
0056
0057 #define TARFILE_START psxftw01_tar
0058 #define TARFILE_SIZE psxftw01_tar_size
0059 #define TARFILE_GZ_START psxftw01_tar_gz
0060 #define TARFILE_GZ_SIZE psxftw01_tar_gz_size
0061
0062 const char rtems_test_name[] = "psxftw01";
0063
0064 void *POSIX_Init (void * argument);
0065
0066 static char file_traverse_order[6][20];
0067 static int file_order;
0068
0069 static int fn_function (const char *fpath, const struct stat *sb,
0070 int tflag, struct FTW *ftwbuf)
0071 {
0072 strcpy(file_traverse_order [file_order], fpath + ftwbuf->base) ;
0073 file_order = file_order + 1;
0074 return 0;
0075 }
0076
0077
0078 T_TEST_CASE(ftw)
0079 {
0080
0081
0082 int r;
0083 char *files_path;
0084 int flags;
0085 int i;
0086
0087 rtems_status_code sc;
0088
0089
0090 sc = Untar_FromMemory_Print(
0091 (void *)TARFILE_START,
0092 TARFILE_SIZE,
0093 &rtems_test_printer
0094 );
0095 T_rsc_success( sc );
0096
0097
0098 char arr_ftw_depth[5][20] = { "test_file", "test_script", "def", "abc", "home" };
0099 char arr_ftw_phys[5][20] = { "home", "test_file", "abc", "def", "test_script" };
0100
0101 files_path = "/home";
0102
0103 flags = 0;
0104 file_order = 0;
0105 flags |= FTW_DEPTH;
0106 r = nftw( files_path, fn_function, 5, flags );
0107 T_psx_success( r );
0108
0109
0110 for (i = 0; i < file_order; i++){
0111 r = strcmp( arr_ftw_depth[i], file_traverse_order[i]);
0112 T_eq_int( r, 0 );
0113 }
0114
0115 flags = 0;
0116 file_order = 0;
0117 flags |= FTW_PHYS;
0118 r = nftw( files_path, fn_function, 5, flags );
0119 T_psx_success(r);
0120
0121
0122 for (i = 0; i < file_order; i++){
0123 r = strcmp( arr_ftw_phys[i], file_traverse_order[i]);
0124 T_eq_int( r, 0 );
0125 }
0126
0127 }
0128
0129 void *POSIX_Init (void * argument)
0130 {
0131 rtems_test_run( (rtems_task_argument) argument, TEST_STATE );
0132 }
0133
0134
0135
0136 #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
0137 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
0138
0139 #define CONFIGURE_MAXIMUM_TASKS 1
0140
0141 #define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 6
0142
0143 #define CONFIGURE_MAXIMUM_POSIX_THREADS 2
0144
0145 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
0146
0147 #define CONFIGURE_POSIX_INIT_THREAD_TABLE
0148
0149 #define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT
0150
0151
0152 #define CONFIGURE_INIT
0153 #include <rtems/confdefs.h>
0154