/ Check-in [fa718960]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Documentation improvements and additional test cases.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | quota-stdio
Files: files | file ages | folders
SHA1: fa71896089538589fb7015d6507e22961e72233b
User & Date: drh 2011-12-02 15:27:41
Context
2011-12-02
15:31
One minor documentation enhancement. check-in: 8cfd3575 user: drh tags: quota-stdio
15:27
Documentation improvements and additional test cases. check-in: fa718960 user: drh tags: quota-stdio
2011-12-01
22:12
Run quota-stdio tests in binary mode so that they work on windows. check-in: 71e4e97d user: drh tags: quota-stdio
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test_quota.h.

    61     61   ** with a zPattern for a quota group that already exists, this routine
    62     62   ** merely updates the iLimit, xCallback, and pArg values for that quota
    63     63   ** group.  If zPattern is new, then a new quota group is created.
    64     64   **
    65     65   ** The zPattern is always compared against the full pathname of the file.
    66     66   ** Even if APIs are called with relative pathnames, SQLite converts the
    67     67   ** name to a full pathname before comparing it against zPattern.  zPattern
    68         -** is a standard glob pattern with the following matching rules:
           68  +** is a glob pattern with the following matching rules:
    69     69   **
    70     70   **      '*'       Matches any sequence of zero or more characters.
    71     71   **
    72     72   **      '?'       Matches exactly one character.
    73     73   **
    74     74   **     [...]      Matches one character from the enclosed list of
    75         -**                characters.
           75  +**                characters.  "]" can be part of the list if it is
           76  +**                the first character.  Within the list "X-Y" matches
           77  +**                characters X or Y or any character in between the
           78  +**                two.  Ex:  "[0-9]" matches any digit.
    76     79   **
    77     80   **     [^...]     Matches one character not in the enclosed list.
           81  +**
           82  +**     /          Matches either / or \.  This allows glob patterns
           83  +**                containing / to work on both unix and windows.
    78     84   **
    79     85   ** Note that, unlike unix shell globbing, the directory separator "/"
    80     86   ** can match a wildcard.  So, for example, the pattern "/abc/xyz/" "*"
    81     87   ** matches any files anywhere in the directory hierarchy beneath
    82         -** /abc/xyz
           88  +** /abc/xyz.
    83     89   **
    84     90   ** If the iLimit for a quota group is set to zero, then the quota group
    85     91   ** is disabled and will be deleted when the last database connection using
    86     92   ** the quota group is closed.
    87     93   **
    88     94   ** Calling this routine on a zPattern that does not exist and with a
    89     95   ** zero iLimit is a no-op.

Changes to test/quota-glob.test.

    28     28      4  abcdefgh  abcdefg   0
    29     29      5  abcdef?   abcdefg   1
    30     30      6  abcdef?   abcdef    0
    31     31      7  abcdef?   abcdefgh  0
    32     32      8  abcdefg   abcdef?   0
    33     33      9  abcdef?   abcdef?   1
    34     34     10  abc/def   abc/def   1
    35         -  11  abc/def   abc\\def  1
           35  +  11  abc//def  abc/def   0
    36     36     12  */abc/*   x/abc/y   1
    37     37     13  */abc/*   /abc/     1
    38     38     16  */abc/*   x///a/ab/abc   0
    39     39     17  */abc/*   x//a/ab/abc/   1
    40     40     16  */abc/*   x///a/ab/abc   0
    41     41     17  */abc/*   x//a/ab/abc/   1
           42  +  18  **/abc/** x//a/ab/abc/   1
           43  +  19  *?/abc/*? x//a/ab/abc/y  1
           44  +  20  ?*/abc/?* x//a/ab/abc/y  1
           45  +  21  {abc[cde]efg}   abcbefg  0
           46  +  22  {abc[cde]efg}   abccefg  1
           47  +  23  {abc[cde]efg}   abcdefg  1
           48  +  24  {abc[cde]efg}   abceefg  1
           49  +  25  {abc[cde]efg}   abcfefg  0
           50  +  26  {abc[^cde]efg}  abcbefg  1
           51  +  27  {abc[^cde]efg}  abccefg  0
           52  +  28  {abc[^cde]efg}  abcdefg  0
           53  +  29  {abc[^cde]efg}  abceefg  0
           54  +  30  {abc[^cde]efg}  abcfefg  1
           55  +  31  {abc[c-e]efg}   abcbefg  0
           56  +  32  {abc[c-e]efg}   abccefg  1
           57  +  33  {abc[c-e]efg}   abcdefg  1
           58  +  34  {abc[c-e]efg}   abceefg  1
           59  +  35  {abc[c-e]efg}   abcfefg  0
           60  +  36  {abc[^c-e]efg}  abcbefg  1
           61  +  37  {abc[^c-e]efg}  abccefg  0
           62  +  38  {abc[^c-e]efg}  abcdefg  0
           63  +  39  {abc[^c-e]efg}  abceefg  0
           64  +  40  {abc[^c-e]efg}  abcfefg  1
           65  +  41  {abc[c-e]efg}   abc-efg  0
           66  +  42  {abc[-ce]efg}   abc-efg  1
           67  +  43  {abc[ce-]efg}   abc-efg  1
           68  +  44  {abc[][*?]efg}  {abc]efg} 1
           69  +  45  {abc[][*?]efg}  {abc*efg} 1
           70  +  46  {abc[][*?]efg}  {abc?efg} 1
           71  +  47  {abc[][*?]efg}  {abc[efg} 1
           72  +  48  {abc[^][*?]efg} {abc]efg} 0
           73  +  49  {abc[^][*?]efg} {abc*efg} 0
           74  +  50  {abc[^][*?]efg} {abc?efg} 0
           75  +  51  {abc[^][*?]efg} {abc[efg} 0
           76  +  52  {abc[^][*?]efg} {abcdefg} 1
           77  +  53  {*[xyz]efg}     {abcxefg} 1
           78  +  54  {*[xyz]efg}     {abcwefg} 0
    42     79   } {
    43     80     do_test quota-glob-$testnum.1 {
    44     81       sqlite3_quota_glob $::pattern $::text
    45     82     } $::ans
    46     83     do_test quota-glob-$testnum.2 {
    47     84       sqlite3_quota_glob $::pattern [string map {/ \\} $::text]
    48     85     } $::ans
    49     86   }
    50     87   finish_test

Changes to test/quota2.test.

    13     13   set testdir [file dirname $argv0]
    14     14   source $testdir/tester.tcl
    15     15   source $testdir/malloc_common.tcl
    16     16   
    17     17   db close
    18     18   sqlite3_quota_initialize "" 1
    19     19   
    20         -file delete -force quota2a
    21         -file delete -force quota2b
    22         -file mkdir quota2a
    23         -file mkdir quota2b
           20  +foreach dir {quota2a quota2b quota2c} {
           21  +  file delete -force $dir
           22  +  file mkdir $dir
           23  +}
    24     24   
    25     25   # The standard_path procedure converts a pathname into a standard format
    26     26   # that is the same across platforms.
    27     27   #
    28     28   unset -nocomplain ::quota_pwd ::quota_mapping
    29     29   set ::quota_pwd [string map {\\ /} [pwd]]
    30     30   set ::quota_mapping [list $::quota_pwd PWD]
................................................................................
   115    115   } {{*/quota2b/* 5000 0} {*/quota2a/* 4000 4000 {PWD/quota2a/xyz.txt 4000 0 0}}}
   116    116   do_test quota1-1.13 {
   117    117     sqlite3_quota_remove quota2a/xyz.txt
   118    118     standard_path [sqlite3_quota_dump]
   119    119   } {{*/quota2b/* 5000 0} {*/quota2a/* 4000 0}}
   120    120   
   121    121   
          122  +set quota {}
          123  +do_test quota2-2.1 {
          124  +  set ::h1 [sqlite3_quota_fopen quota2c/xyz.txt w+b]
          125  +  sqlite3_quota_fwrite $::h1 1 7000 $bigtext
          126  +} {7000}
          127  +do_test quota2-2.2 {
          128  +  set ::quota
          129  +} {}
          130  +do_test quota2-2.3 {
          131  +  sqlite3_quota_rewind $::h1
          132  +  set ::x [sqlite3_quota_fread $::h1 1001 7]
          133  +  string length $::x
          134  +} {6006}
          135  +do_test quota2-2.4 {
          136  +  string match $::x [string range $::bigtext 0 6005]
          137  +} {1}
          138  +do_test quota2-2.5 {
          139  +  sqlite3_quota_fseek $::h1 0 SEEK_END
          140  +  sqlite3_quota_ftell $::h1
          141  +} {7000}
          142  +do_test quota2-2.6 {
          143  +  sqlite3_quota_fseek $::h1 -100 SEEK_END
          144  +  sqlite3_quota_ftell $::h1
          145  +} {6900}
          146  +do_test quota2-2.7 {
          147  +  sqlite3_quota_fseek $::h1 -100 SEEK_CUR
          148  +  sqlite3_quota_ftell $::h1
          149  +} {6800}
          150  +do_test quota2-2.8 {
          151  +  sqlite3_quota_fseek $::h1 50 SEEK_CUR
          152  +  sqlite3_quota_ftell $::h1
          153  +} {6850}
          154  +do_test quota2-2.9 {
          155  +  sqlite3_quota_fseek $::h1 50 SEEK_SET
          156  +  sqlite3_quota_ftell $::h1
          157  +} {50}
          158  +do_test quota2-2.10 {
          159  +  sqlite3_quota_rewind $::h1
          160  +  sqlite3_quota_ftell $::h1
          161  +} {0}
          162  +do_test quota2-2.11 {
          163  +  standard_path [sqlite3_quota_dump]
          164  +} {{*/quota2b/* 5000 0} {*/quota2a/* 4000 0}}
          165  +do_test quota1-2.12 {
          166  +  sqlite3_quota_fclose $::h1
          167  +  standard_path [sqlite3_quota_dump]
          168  +} {{*/quota2b/* 5000 0} {*/quota2a/* 4000 0}}
   122    169   
   123    170   catch { sqlite3_quota_shutdown }
   124    171   catch { unset quota_request_ok }
   125    172   finish_test