test_sqlite.c (3354B)
1 /* 2 This file is part of libextractor. 3 Copyright (C) 2026 Vidyut Samanta and Christian Grothoff 4 5 libextractor is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published 7 by the Free Software Foundation; either version 3, or (at your 8 option) any later version. 9 10 libextractor is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with libextractor; see the file COPYING. If not, write to the 17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18 Boston, MA 02110-1301, USA. 19 */ 20 /** 21 * @file plugins/test_sqlite.c 22 * @brief testcase for the sqlite plugin 23 * @author Christian Grothoff 24 */ 25 #include "platform.h" 26 #include "test_lib.h" 27 28 29 /** 30 * Shorthand for a plain UTF-8 text solution. 31 */ 32 #define TEXT_SOLUTION(type, value) \ 33 { (type), EXTRACTOR_METAFORMAT_UTF8, "text/plain", \ 34 (value), strlen (value) + 1, 0, 0, NULL } 35 36 37 /** 38 * Main function for the sqlite testcase. 39 * 40 * @param argc number of arguments (ignored) 41 * @param argv arguments (ignored) 42 * @return 0 on success 43 */ 44 int 45 main (int argc, char *argv[]) 46 { 47 struct SolutionData sqlite_db_sol[] = { 48 TEXT_SOLUTION (EXTRACTOR_METATYPE_MIMETYPE, 49 "application/vnd.sqlite3"), 50 /* PRAGMA page_size = 1024 */ 51 TEXT_SOLUTION (EXTRACTOR_METATYPE_BLOCK_SIZE, 52 "1024"), 53 /* PRAGMA journal_mode = WAL leaves write format version 2 behind */ 54 TEXT_SOLUTION (EXTRACTOR_METATYPE_JOURNAL_MODE, 55 "wal"), 56 /* file change counter, in step with version-valid-for */ 57 TEXT_SOLUTION (EXTRACTOR_METATYPE_CHANGE_COUNTER, 58 "11"), 59 /* five 1 KiB pages */ 60 TEXT_SOLUTION (EXTRACTOR_METATYPE_ENTRY_COUNT, 61 "5"), 62 /* one freelist page left behind by the DELETE */ 63 TEXT_SOLUTION (EXTRACTOR_METATYPE_FREE_SPACE, 64 "1024"), 65 TEXT_SOLUTION (EXTRACTOR_METATYPE_SCHEMA_VERSION, 66 "schema cookie 4"), 67 /* PRAGMA user_version = 4242 */ 68 TEXT_SOLUTION (EXTRACTOR_METATYPE_SCHEMA_VERSION, 69 "user_version 4242"), 70 /* PRAGMA auto_vacuum = 2 */ 71 TEXT_SOLUTION (EXTRACTOR_METATYPE_ATTRIBUTES, 72 "incremental vacuum"), 73 TEXT_SOLUTION (EXTRACTOR_METATYPE_CHARACTER_SET, 74 "UTF-8"), 75 /* PRAGMA application_id = 1279613012 == 0x4c455854 */ 76 TEXT_SOLUTION (EXTRACTOR_METATYPE_APPLICATION_ID, 77 "1279613012"), 78 TEXT_SOLUTION (EXTRACTOR_METATYPE_APPLICATION_ID, 79 "LEXT"), 80 /* pinned to 3.45.1 by the generator */ 81 TEXT_SOLUTION (EXTRACTOR_METATYPE_MODIFIED_BY_SOFTWARE, 82 "SQLite 3.45.1"), 83 /* 5 pages of 1024 bytes */ 84 TEXT_SOLUTION (EXTRACTOR_METATYPE_VOLUME_SIZE, 85 "5120"), 86 { 0, 0, NULL, NULL, 0, -1, 0, NULL } 87 }; 88 struct ProblemSet ps[] = { 89 { "testdata/sqlite_test.db", 90 sqlite_db_sol }, 91 { NULL, NULL } 92 }; 93 94 (void) argc; 95 (void) argv; 96 return ET_main ("sqlite", ps); 97 } 98 99 100 /* end of test_sqlite.c */