/ Check-in [55de6f14]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Adjustments to test numbers for the 'zonefile' extension.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | zonefile
Files: files | file ages | folders
SHA3-256: 55de6f14d49342394397c0dc29c1e98c927ef99d57ec1f71c79099f584be20d1
User & Date: mistachkin 2018-02-27 15:42:29
Context
2018-02-27
15:47
Enhance test 'zonefile1-6.5' to account for platform differences. check-in: 8b617840 user: mistachkin tags: zonefile
15:42
Adjustments to test numbers for the 'zonefile' extension. check-in: 55de6f14 user: mistachkin tags: zonefile
14:26
Have the zonefile extension use binary instead of text keys. check-in: 39a4267f user: dan tags: zonefile
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/zonefile/zonefile1.test.

380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
...
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
...
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
...
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
} {1 {failed to open file "test.dir" for writing}}

do_catchsql_test 6.4 {
  CREATE VIRTUAL TABLE zzz USING zonefile;
  INSERT INTO zzz_files(filename) VALUES('nosuchfile.zonefile');
} {1 {failed to open file "nosuchfile.zonefile" for reading}}

do_catchsql_test 6.4 {
  INSERT INTO zzz_files(filename) VALUES('test.dir');
} {1 {failed to read zonefile header from file "test.dir"}}

#-------------------------------------------------------------------------
# Check that errors generated when building a dictionary are handled.
# The zstd library routines for building a dictionary throw an error
# if they are provided with too little data.
................................................................................
  CREATE VIRTUAL TABLE nm USING zonefile(cachesiza=b)
} {1 {parse error in option: cachesiza=b}}

#-------------------------------------------------------------------------
#
reset_db
load_static_extension db zonefile
do_execsql_test 11.0 {
  CREATE TABLE data(k INTEGER PRIMARY KEY, v BLOB);
  WITH s(i) AS (
    SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<250
  )
  INSERT INTO data SELECT i, randomblob(100) FROM s;
  CREATE VIEW v1 AS SELECT k, -1 AS frame, -1 AS idx, v FROM data;
  SELECT zonefile_write('test1.zonefile', 'v1');
................................................................................
  2   "k >= 100"
  3   "k <= 100"
  4   "k < 55"
  5   "k LIKE '1%'"
  6   "k BETWEEN 10 AND 20"
  7   "k > 100 AND k < 200"
} {
  do_execsql_test 11.1.$tn.1 [subst {
    SELECT count(*) FROM nm WHERE $cond
  }] [db one "SELECT count(*) FROM data WHERE $cond"]

  do_execsql_test 11.1.$tn.2 [subst {
    SELECT count(*) FROM nm WHERE $cond AND
      v!=(SELECT v FROM data WHERE k=nm.k);
  }] 0
}

close [open test1.zonefile w+]
do_catchsql_test 11.2.1 {
  SELECT * FROM nm WHERE k=24;
} {1 {SQL logic error}}
forcedelete test1.zonefile
do_catchsql_test 11.2.2 {
  SELECT * FROM nm WHERE k=24;
} {1 {failed to open file "test1.zonefile" for reading}}

do_catchsql_test 11.3.1 {
  DELETE FROM nm_shadow_file;
  SELECT * FROM nm WHERE k=24;
} {1 {database disk image is malformed}}
do_catchsql_test 11.3.2 {
  DROP TABLE nm_shadow_file;
  SELECT * FROM nm WHERE k=24;
} {1 {no such table: main.nm_shadow_file}}
db close
sqlite3 db test.db
load_static_extension db zonefile
do_catchsql_test 11.3.3 {
  SELECT * FROM nm WHERE k=24;
} {1 {no such table: main.nm_shadow_file}}

#-------------------------------------------------------------------------
#
reset_db
load_static_extension db zonefile
do_execsql_test 11.0 {
  CREATE TABLE data(k INTEGER PRIMARY KEY, frame, idx, v BLOB);
  INSERT INTO data VALUES(1, 1, -1, randomblob(200));
  INSERT INTO data VALUES(2, 2, -1, randomblob(200));
  INSERT INTO data VALUES(3, 3, -1, randomblob(200));
  SELECT zonefile_write('test.zonefile', 'data',
  '{"encryptionType":"xor","encryptionKey":"pass","debugEncryptionKeyText":1}'
  );
................................................................................

  CREATE VIRTUAL TABLE nm USING zonefile(cachesize=2);
  INSERT INTO nm_files(filename,ekey) VALUES('test.zonefile','pass');
} {{}}

set i 0
foreach id {1 2 3 2 3 1} {
  do_execsql_test 11.1.$i {
    SELECT data.v=nm.v FROM data,nm WHERE data.k=$id AND nm.k=$id
  } 1
  incr i
}

if {[file exists /dev/null]} {
  do_catchsql_test 11.2 {
    INSERT INTO nm_files(filename) VALUES('/dev/null');
  } {1 {failed to read zonefile header from file "/dev/null"}}
}

finish_test








|







 







|







 







|



|






|



|



|



|






|







|







 







|






|






380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
...
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
...
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
...
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
} {1 {failed to open file "test.dir" for writing}}

do_catchsql_test 6.4 {
  CREATE VIRTUAL TABLE zzz USING zonefile;
  INSERT INTO zzz_files(filename) VALUES('nosuchfile.zonefile');
} {1 {failed to open file "nosuchfile.zonefile" for reading}}

do_catchsql_test 6.5 {
  INSERT INTO zzz_files(filename) VALUES('test.dir');
} {1 {failed to read zonefile header from file "test.dir"}}

#-------------------------------------------------------------------------
# Check that errors generated when building a dictionary are handled.
# The zstd library routines for building a dictionary throw an error
# if they are provided with too little data.
................................................................................
  CREATE VIRTUAL TABLE nm USING zonefile(cachesiza=b)
} {1 {parse error in option: cachesiza=b}}

#-------------------------------------------------------------------------
#
reset_db
load_static_extension db zonefile
do_execsql_test 13.0 {
  CREATE TABLE data(k INTEGER PRIMARY KEY, v BLOB);
  WITH s(i) AS (
    SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<250
  )
  INSERT INTO data SELECT i, randomblob(100) FROM s;
  CREATE VIEW v1 AS SELECT k, -1 AS frame, -1 AS idx, v FROM data;
  SELECT zonefile_write('test1.zonefile', 'v1');
................................................................................
  2   "k >= 100"
  3   "k <= 100"
  4   "k < 55"
  5   "k LIKE '1%'"
  6   "k BETWEEN 10 AND 20"
  7   "k > 100 AND k < 200"
} {
  do_execsql_test 13.1.$tn.1 [subst {
    SELECT count(*) FROM nm WHERE $cond
  }] [db one "SELECT count(*) FROM data WHERE $cond"]

  do_execsql_test 13.1.$tn.2 [subst {
    SELECT count(*) FROM nm WHERE $cond AND
      v!=(SELECT v FROM data WHERE k=nm.k);
  }] 0
}

close [open test1.zonefile w+]
do_catchsql_test 13.2.1 {
  SELECT * FROM nm WHERE k=24;
} {1 {SQL logic error}}
forcedelete test1.zonefile
do_catchsql_test 13.2.2 {
  SELECT * FROM nm WHERE k=24;
} {1 {failed to open file "test1.zonefile" for reading}}

do_catchsql_test 13.3.1 {
  DELETE FROM nm_shadow_file;
  SELECT * FROM nm WHERE k=24;
} {1 {database disk image is malformed}}
do_catchsql_test 13.3.2 {
  DROP TABLE nm_shadow_file;
  SELECT * FROM nm WHERE k=24;
} {1 {no such table: main.nm_shadow_file}}
db close
sqlite3 db test.db
load_static_extension db zonefile
do_catchsql_test 13.3.3 {
  SELECT * FROM nm WHERE k=24;
} {1 {no such table: main.nm_shadow_file}}

#-------------------------------------------------------------------------
#
reset_db
load_static_extension db zonefile
do_execsql_test 14.0 {
  CREATE TABLE data(k INTEGER PRIMARY KEY, frame, idx, v BLOB);
  INSERT INTO data VALUES(1, 1, -1, randomblob(200));
  INSERT INTO data VALUES(2, 2, -1, randomblob(200));
  INSERT INTO data VALUES(3, 3, -1, randomblob(200));
  SELECT zonefile_write('test.zonefile', 'data',
  '{"encryptionType":"xor","encryptionKey":"pass","debugEncryptionKeyText":1}'
  );
................................................................................

  CREATE VIRTUAL TABLE nm USING zonefile(cachesize=2);
  INSERT INTO nm_files(filename,ekey) VALUES('test.zonefile','pass');
} {{}}

set i 0
foreach id {1 2 3 2 3 1} {
  do_execsql_test 14.1.$i {
    SELECT data.v=nm.v FROM data,nm WHERE data.k=$id AND nm.k=$id
  } 1
  incr i
}

if {[file exists /dev/null]} {
  do_catchsql_test 14.2 {
    INSERT INTO nm_files(filename) VALUES('/dev/null');
  } {1 {failed to read zonefile header from file "/dev/null"}}
}

finish_test

Changes to ext/zonefile/zonefileenc.test.

7
8
9
10
11
12
13


14
15
16
17
18
19
20
...
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# The focus of this file is testing the zonefile extension.
#



if {![info exists testdir]} {
  set testdir [file join [file dirname [info script]] .. .. test]
}
source [file join $testdir tester.tcl]
set testprefix zonefileenc

................................................................................
    ) FROM p;
  } "1 {unsupported encryption method: $id}"
}

foreach {tn alg} {
  1 nosuchmethod! 
} {
  do_catchsql_test 2.1.$tn {
    WITH p(n,v) AS (
        VALUES('encryptionType', $alg) UNION ALL
        VALUES('debugEncryptionKeyText', 1) UNION ALL
        VALUES('encryptionKey', 'secret')
    )
    SELECT zonefile_write('test' || $i || '.zonefile', 'zz', 
        json_group_object(n, v)







>
>







 







|







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# The focus of this file is testing the zonefile extension.
#

package require Tcl 8.6

if {![info exists testdir]} {
  set testdir [file join [file dirname [info script]] .. .. test]
}
source [file join $testdir tester.tcl]
set testprefix zonefileenc

................................................................................
    ) FROM p;
  } "1 {unsupported encryption method: $id}"
}

foreach {tn alg} {
  1 nosuchmethod! 
} {
  do_catchsql_test 2.2.$tn {
    WITH p(n,v) AS (
        VALUES('encryptionType', $alg) UNION ALL
        VALUES('debugEncryptionKeyText', 1) UNION ALL
        VALUES('encryptionKey', 'secret')
    )
    SELECT zonefile_write('test' || $i || '.zonefile', 'zz', 
        json_group_object(n, v)

Changes to ext/zonefile/zonefilefault.test.

235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
  execsql { SELECT v IS NULL FROM zone2 WHERE k = 2 }
} -test {
  faultsim_test_result {0 0}
}

#-------------------------------------------------------------------------
reset_db
do_faultsim_test 4.3 -faults oom* -prep {
  faultsim_restore_and_reopen
} -body {
  load_static_extension db zonefile
} -test {
  faultsim_test_result {0 {}} {1 {initialization of zonefile failed: }}
}

finish_test








|









235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
  execsql { SELECT v IS NULL FROM zone2 WHERE k = 2 }
} -test {
  faultsim_test_result {0 0}
}

#-------------------------------------------------------------------------
reset_db
do_faultsim_test 4.4 -faults oom* -prep {
  faultsim_restore_and_reopen
} -body {
  load_static_extension db zonefile
} -test {
  faultsim_test_result {0 {}} {1 {initialization of zonefile failed: }}
}

finish_test