OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [io/] [fileio/] [current/] [tests/] [fnmatch.c] - Blame information for rev 825

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      fnmatch.c
4
//
5
//      Test fnmatch function
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 2007 Free Software Foundation, Inc.                        
12
//
13
// eCos is free software; you can redistribute it and/or modify it under    
14
// the terms of the GNU General Public License as published by the Free     
15
// Software Foundation; either version 2 or (at your option) any later      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
//==========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):           asl
43
// Contributors:        asl
44
// Date:                2007-01-27
45
// Purpose:             Test fnmatch function.
46
// Description:         //              
47
//
48
//####DESCRIPTIONEND####
49
//
50
//==========================================================================
51
 
52
#include <pkgconf/io_fileio.h>
53
 
54
#ifndef CYGPKG_FILEIO_FNMATCH
55
# define NA_MSG "FNMATCH function not available"
56
#endif
57
 
58
#include <cyg/infra/testcase.h>
59
 
60
#ifndef NA_MSG
61
#include <cyg/infra/cyg_type.h>
62
#include <cyg/infra/diag.h>
63
 
64
#include <fnmatch.h>
65
 
66
//==========================================================================
67
// main
68
 
69
int main( int argc, char **argv )
70
{
71
  int i;
72
  cyg_bool failed = false;
73
 
74
  struct
75
  {
76
    const int result;
77
    const int flags;
78
    const char * string;
79
    const char * pattern;
80
  } test_case[] = {
81
    { 0,           0, "abc", "abc" },               /*  0 */
82
    { FNM_NOMATCH, 0, "cba", "abc" },
83
    { 0,           0, "abc", "a*"  },
84
    { FNM_NOMATCH, 0, "abc", "b*"  },
85
    { 0,           0, "abc", "[abc]*" },
86
    { FNM_NOMATCH, 0, "abc", "[def]*" },
87
    { FNM_NOMATCH, 0, "abc", "*[def]*" },
88
    { 0,           0, "a/b", "a/b" },
89
    { FNM_NOMATCH, 0, "a/b", "a/a" },
90
    { FNM_NOMATCH, 0, "a/b", "b/b" },
91
 
92
    { 0,           0,            "a b", "a\\ b"},  /* 10 */
93
    { FNM_NOMATCH, FNM_NOESCAPE, "a b", "a\\ b"},
94
 
95
    { 0,           0,            "a/b", "a*b" },
96
    { 0,           0,            "a/b", "a?b" },
97
    { 0,           0,            "a/b", "a[/]b" },
98
    { FNM_NOMATCH, FNM_PATHNAME, "a/b", "a*b"},
99
    { FNM_NOMATCH, FNM_PATHNAME, "a/b", "a?b"},
100
    { FNM_NOMATCH, FNM_PATHNAME, "a/b", "a[/]b"},
101
    { 0,           FNM_PATHNAME, "a/b", "a/b"},
102
 
103
    { 0,           0,          ".abc", "?abc" },
104
    { 0,           0,          ".abc", "*abc" },  /* 20 */
105
    { 0,           0,          ".abc", "[.]abc" },
106
    { 0,           0,          ".abc", ".abc" },
107
    { FNM_NOMATCH, FNM_PERIOD, ".abc", "?abc" },
108
    { FNM_NOMATCH, FNM_PERIOD, ".abc", "*abc" },
109
    { 0,           FNM_PERIOD, ".abc", "[.]abc" },
110
    { 0,           FNM_PERIOD, ".abc", ".abc" },
111
 
112
    { 0,           0,                       "/.abc", "/?abc" },
113
    { 0,           0,                       "/.abc", "/*abc" },
114
    { 0,           0,                       "/.abc", "/[.]abc" },
115
    { 0,           0,                       "/.abc", "/.abc" },  /* 30 */
116
    { FNM_NOMATCH, FNM_PERIOD|FNM_PATHNAME, "/.abc", "/?abc" },
117
    { FNM_NOMATCH, FNM_PERIOD|FNM_PATHNAME, "/.abc", "/*abc" },
118
    { 0,           FNM_PERIOD|FNM_PATHNAME, "/.abc", "/[.]abc" },
119
    { 0,           FNM_PERIOD|FNM_PATHNAME, "/.abc", "/.abc" }
120
  };
121
 
122
  CYG_TEST_INIT();
123
 
124
  for (i=0; i < CYG_NELEM(test_case); i++) {
125
    if (test_case[i].result !=
126
        fnmatch(test_case[i].pattern,
127
                test_case[i].string,
128
                test_case[i].flags)) {
129
      diag_printf("<INFO>: test number %d failed\n", i);
130
      failed = true;
131
    }
132
  }
133
 
134
  if (failed) {
135
    CYG_TEST_FAIL_FINISH("fnmatch failed");
136
  } else {
137
    CYG_TEST_PASS_FINISH("fnmatch passed");
138
  }
139
}
140
 
141
#else 
142
 
143
//==========================================================================
144
// main
145
 
146
int main( int argc, char **argv )
147
{
148
    CYG_TEST_INIT();
149
 
150
    CYG_TEST_NA(NA_MSG);
151
}
152
 
153
#endif
154
 
155
// -------------------------------------------------------------------------
156
// EOF fnmatch.c

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.