pcache2.test 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # 2008 September 15
  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. #
  12. # This file is focused on testing the pcache module.
  13. #
  14. # $Id: pcache2.test,v 1.5 2009/07/18 14:36:24 danielk1977 Exp $
  15. set testdir [file dirname $argv0]
  16. source $testdir/tester.tcl
  17. # Set up a pcache memory pool so that we can easily track how many
  18. # pages are being used for cache.
  19. #
  20. do_test pcache2-1.1 {
  21. db close
  22. sqlite3_reset_auto_extension
  23. sqlite3_shutdown
  24. sqlite3_config_pagecache 6000 100
  25. sqlite3_initialize
  26. autoinstall_test_functions
  27. sqlite3_status SQLITE_STATUS_PAGECACHE_USED 1
  28. sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0
  29. } {0 0 0}
  30. # Open up two database connections to separate files.
  31. #
  32. do_test pcache2-1.2 {
  33. forcedelete test.db test.db-journal
  34. sqlite3 db test.db
  35. db eval {PRAGMA cache_size=10}
  36. lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 1
  37. } {2}
  38. do_test pcache2-1.3 {
  39. forcedelete test2.db test2.db-journal
  40. sqlite3 db2 test2.db
  41. db2 eval {PRAGMA cache_size=50}
  42. lindex [sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0] 1
  43. } {4}
  44. # Make lots of changes on the first connection. Verify that the
  45. # page cache usage does not grow to consume the page space set aside
  46. # for the second connection.
  47. #
  48. do_test pcache2-1.4 {
  49. db eval {
  50. CREATE TABLE t1(a,b);
  51. CREATE TABLE t2(x,y);
  52. INSERT INTO t1 VALUES(1, zeroblob(800));
  53. INSERT INTO t1 VALUES(2, zeroblob(800));
  54. INSERT INTO t2 SELECT * FROM t1;
  55. INSERT INTO t1 SELECT x+2, y FROM t2;
  56. INSERT INTO t2 SELECT a+10, b FROM t1;
  57. INSERT INTO t1 SELECT x+10, y FROM t2;
  58. INSERT INTO t2 SELECT a+100, b FROM t1;
  59. INSERT INTO t1 SELECT x+100, y FROM t2;
  60. INSERT INTO t2 SELECT a+1000, b FROM t1;
  61. INSERT INTO t1 SELECT x+1000, y FROM t2;
  62. }
  63. sqlite3_status SQLITE_STATUS_PAGECACHE_USED 0
  64. } {0 13 13}
  65. db close
  66. catch {db2 close}
  67. sqlite3_reset_auto_extension
  68. sqlite3_shutdown
  69. sqlite3_config_pagecache 0 0
  70. sqlite3_initialize
  71. autoinstall_test_functions
  72. finish_test