win32longpath.test 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. # 2013 August 27
  2. #
  3. # The author disclaims copyright to this source code. In place of
  4. # a legal notice, here is a blessing:
  5. #
  6. # May you do good and not evil.
  7. # May you find forgiveness for yourself and forgive others.
  8. # May you share freely, never taking more than you give.
  9. #
  10. #***********************************************************************
  11. # This file implements regression tests for SQLite library. The
  12. # focus of this script is testing the file name handling provided
  13. # by the "win32-longpath" VFS.
  14. #
  15. if {$tcl_platform(platform)!="windows"} return
  16. set testdir [file dirname $argv0]
  17. source $testdir/tester.tcl
  18. set testprefix win32longpath
  19. db close
  20. set path [file nativename [get_pwd]]
  21. sqlite3 db [file join $path test.db] -vfs win32-longpath
  22. do_test 1.1 {
  23. db eval {
  24. BEGIN EXCLUSIVE;
  25. CREATE TABLE t1(x);
  26. INSERT INTO t1 VALUES(1);
  27. INSERT INTO t1 VALUES(2);
  28. INSERT INTO t1 VALUES(3);
  29. INSERT INTO t1 VALUES(4);
  30. SELECT x FROM t1 ORDER BY x;
  31. COMMIT;
  32. }
  33. } {1 2 3 4}
  34. set longPath(1) \\\\?\\$path\\[pid]
  35. make_win32_dir $longPath(1)
  36. set longPath(2) $longPath(1)\\[string repeat X 255]
  37. make_win32_dir $longPath(2)
  38. set longPath(3) $longPath(2)\\[string repeat Y 255]
  39. make_win32_dir $longPath(3)
  40. set fileName $longPath(3)\\test.db
  41. do_test 1.2 {
  42. list [catch {sqlite3 db2 [string range $fileName 4 end]} msg] $msg
  43. } {1 {unable to open database file}}
  44. sqlite3 db3 $fileName -vfs win32-longpath
  45. do_test 1.3 {
  46. db3 eval {
  47. BEGIN EXCLUSIVE;
  48. CREATE TABLE t1(x);
  49. INSERT INTO t1 VALUES(5);
  50. INSERT INTO t1 VALUES(6);
  51. INSERT INTO t1 VALUES(7);
  52. INSERT INTO t1 VALUES(8);
  53. SELECT x FROM t1 ORDER BY x;
  54. COMMIT;
  55. }
  56. } {5 6 7 8}
  57. db3 close
  58. # puts " Database exists \{[exists_win32_path $fileName]\}"
  59. sqlite3 db3 $fileName -vfs win32-longpath
  60. do_test 1.4 {
  61. db3 eval {
  62. PRAGMA journal_mode = WAL;
  63. }
  64. } {wal}
  65. do_test 1.5 {
  66. db3 eval {
  67. BEGIN EXCLUSIVE;
  68. INSERT INTO t1 VALUES(9);
  69. INSERT INTO t1 VALUES(10);
  70. INSERT INTO t1 VALUES(11);
  71. INSERT INTO t1 VALUES(12);
  72. SELECT x FROM t1 ORDER BY x;
  73. COMMIT;
  74. }
  75. } {5 6 7 8 9 10 11 12}
  76. db3 close
  77. # puts " Database exists \{[exists_win32_path $fileName]\}"
  78. do_delete_win32_file $fileName
  79. # puts " Files remaining \{[find_win32_file $longPath(3)\\*]\}"
  80. do_remove_win32_dir $longPath(3)
  81. do_remove_win32_dir $longPath(2)
  82. do_remove_win32_dir $longPath(1)
  83. finish_test