diff --git a/Regression/bz428153-segfault-using-EXPLAIN/PURPOSE b/Regression/bz428153-segfault-using-EXPLAIN/PURPOSE new file mode 100644 index 0000000..f2b9e3b --- /dev/null +++ b/Regression/bz428153-segfault-using-EXPLAIN/PURPOSE @@ -0,0 +1,57 @@ +PURPOSE of /CoreOS/sqlite/Regression/bz428153-segfault-using-EXPLAIN +Description: Test for bz428153 (segfault using EXPLAIN) +Author: Matej Susta +Bug summary: segfault using EXPLAIN +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=428153 + +Description: + +Description of problem: +[dmalcolm@cassandra ~]$ gdb sqlite3 +GNU gdb Red Hat Linux (6.5-16.el5rh) +Copyright (C) 2006 Free Software Foundation, Inc. +GDB is free software, covered by the GNU General Public License, and you are +welcome to change it and/or distribute copies of it under certain conditions. +Type "show copying" to see the conditions. +There is absolutely no warranty for GDB. Type "show warranty" for details. +This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db +library "/lib/libthread_db.so.1". + +(gdb) run +Starting program: /usr/bin/sqlite3 +[Thread debugging using libthread_db enabled] +[New Thread -1208596800 (LWP 18243)] +SQLite version 3.3.6 +Enter ".help" for instructions +sqlite> create table foo ( bar varchar(40) ); +sqlite> select * from foo; +sqlite> explain select * from foo; + +Program received signal SIGSEGV, Segmentation fault. +[Switching to Thread -1208596800 (LWP 18243)] +0x42807353 in strlen () from /lib/libc.so.6 +(gdb) bt +#0 0x42807353 in strlen () from /lib/libc.so.6 +#1 0x42a917e7 in sqlite3VdbeList (p=0x85e5c38) at ./src/vdbeaux.c:659 +#2 0x42a8ed9f in sqlite3_step (pStmt=0x85e5c38) at ./src/vdbeapi.c:219 +#3 0x42a97655 in sqlite3_exec (db=0x85e2058, zSql=0x85e5f90 "explain select * +from foo;", + xCallback=0x8049fc0 , pArg=0xbfca962c, pzErrMsg=0xbfca95d8) at +./src/legacy.c:78 +#4 0x0804cae1 in process_input (p=0xbfca962c, in=0x0) at ./src/shell.c:1495 +#5 0x0804d32d in main (argc=1, argv=0xbfcaabe4) at ./src/shell.c:1786 +#6 0x427b0dec in __libc_start_main () from /lib/libc.so.6 +#7 0x08049171 in _start () +(gdb) up +#1 0x42a917e7 in sqlite3VdbeList (p=0x85e5c38) at ./src/vdbeaux.c:659 +659 pMem->n = strlen(pMem->z); +(gdb) p *pMem +$1 = {i = 0, r = 0, z = 0x8000
, n = 0, flags = 162, + type = 0 '\0', enc = 0 '\0', xDel = 0, zShort = '\0' } + + +Version-Release number of selected component (if applicable): +sqlite-3.3.6-2 + +How reproducible: +100% diff --git a/Regression/bz428153-segfault-using-EXPLAIN/expected-3.26 b/Regression/bz428153-segfault-using-EXPLAIN/expected-3.26 new file mode 100644 index 0000000..ab52965 --- /dev/null +++ b/Regression/bz428153-segfault-using-EXPLAIN/expected-3.26 @@ -0,0 +1,11 @@ +addr opcode p1 p2 p3 p4 p5 comment +---- ------------- ---- ---- ---- ------------- -- ------------- +0 Init 0 7 0 00 Start at 7 +1 OpenRead 0 2 0 1 00 root=2 iDb=0; foo +2 Rewind 0 6 0 00 +3 Column 0 0 1 00 r[1]=foo.bar +4 ResultRow 1 1 0 00 output=r[1] +5 Next 0 3 0 01 +6 Halt 0 0 0 00 +7 Transaction 0 0 1 0 01 usesStmtJournal=0 +8 Goto 0 1 0 00 diff --git a/Regression/bz428153-segfault-using-EXPLAIN/expected-3.34 b/Regression/bz428153-segfault-using-EXPLAIN/expected-3.34 new file mode 100644 index 0000000..80a2527 --- /dev/null +++ b/Regression/bz428153-segfault-using-EXPLAIN/expected-3.34 @@ -0,0 +1,11 @@ +addr opcode p1 p2 p3 p4 p5 comment +---- ------------- ---- ---- ---- ------------- -- ------------- +0 Init 0 7 0 0 Start at 7 +1 OpenRead 0 2 0 1 0 root=2 iDb=0; foo +2 Rewind 0 6 0 0 +3 Column 0 0 1 0 r[1]=foo.bar +4 ResultRow 1 1 0 0 output=r[1] +5 Next 0 3 0 1 +6 Halt 0 0 0 0 +7 Transaction 0 0 1 0 1 usesStmtJournal=0 +8 Goto 0 1 0 0 diff --git a/Regression/bz428153-segfault-using-EXPLAIN/expected-3.6 b/Regression/bz428153-segfault-using-EXPLAIN/expected-3.6 new file mode 100644 index 0000000..195a8fc --- /dev/null +++ b/Regression/bz428153-segfault-using-EXPLAIN/expected-3.6 @@ -0,0 +1,13 @@ +0|Trace|0|0|0||00| +1|Goto|0|9|0||00| +2|OpenRead|0|2|0|1|00| +3|Rewind|0|7|0||00| +4|Column|0|0|1||00| +5|ResultRow|1|1|0||00| +6|Next|0|4|0||01| +7|Close|0|0|0||00| +8|Halt|0|0|0||00| +9|Transaction|0|0|0||00| +10|VerifyCookie|0|1|0||00| +11|TableLock|0|2|0|foo|00| +12|Goto|0|2|0||00| diff --git a/Regression/bz428153-segfault-using-EXPLAIN/main.fmf b/Regression/bz428153-segfault-using-EXPLAIN/main.fmf new file mode 100644 index 0000000..ca3f904 --- /dev/null +++ b/Regression/bz428153-segfault-using-EXPLAIN/main.fmf @@ -0,0 +1,14 @@ +summary: Sanity test for sqlite database +description: '' +contact: Filip Janus +component: +- sqlite +path: /basic/ +framework: beakerlib +recommend: +- sqlite +duration: 5m +enabled: true +tag: +- Tier1 +- sqlite diff --git a/Regression/bz428153-segfault-using-EXPLAIN/runtest.sh b/Regression/bz428153-segfault-using-EXPLAIN/runtest.sh new file mode 100755 index 0000000..8736b86 --- /dev/null +++ b/Regression/bz428153-segfault-using-EXPLAIN/runtest.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# vim: dict=/usr/share/rhts-library/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/sqlite/Regression/bz428153-segfault-using-EXPLAIN +# Description: Test for bz428153 (segfault using EXPLAIN) +# Author: Matej Susta +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2009 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include beakerlib environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="sqlite" + +rlJournalStart + rlPhaseStartSetup Setup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory" + rlRun "VER=`sqlite3 -version | cut -d' ' -f 1`" 0 "Checking SQLite version" # Check for version + rlRun "MAJOR=`echo $VER | cut -d'.' -f 1`" + rlRun "MINOR=`echo $VER | cut -d'.' -f 2`" + rlPhaseEnd + + rlPhaseStartTest Testing + rlAssertExists $TmpDir + rlRun "sqlite3 $TmpDir/test.db 'create table foo (bar varchar(10));'" 0 "Creating DB and test table" # Just create a db with dumb table + rlRun "sqlite3 $TmpDir/test.db 'explain select * from foo;' >$TmpDir/output" 0 "Executing EXPECT command" # Segfault reproducer + if [[ $MAJOR -ge 3 ]]; then + if [[ $MINOR -lt 26 ]]; then + rlRun "diff ./expected-3.6 $TmpDir/output" 0 "Extra-supported version: checking output sanity" + elif [[ $MINOR -lt 34 ]]; then + rlRun "diff ./expected-3.26 $TmpDir/output" 0 "Extra-supported version: checking output sanity" + else + rlRun "diff ./expected-3.34 $TmpDir/output" 0 "Extra-supported version: checking output sanity" + cat $TmpDir/output + fi + fi + rlPhaseEnd + + rlPhaseStartCleanup Cleanup + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalPrintText + diff --git a/Regression/bz504634-Sqlite-PRAGMA-user-version-causes-a-segfault-in/PURPOSE b/Regression/bz504634-Sqlite-PRAGMA-user-version-causes-a-segfault-in/PURPOSE new file mode 100644 index 0000000..1e23c60 --- /dev/null +++ b/Regression/bz504634-Sqlite-PRAGMA-user-version-causes-a-segfault-in/PURPOSE @@ -0,0 +1,5 @@ +PURPOSE of /CoreOS/sqlite/Regression/bz504634-Sqlite-PRAGMA-user-version-causes-a-segfault-in +Description: Test for BZ#504634 (Sqlite "PRAGMA user_version" causes a segfault in) +Author: Jan Scotka +Bug summary: Sqlite "PRAGMA user_version" causes a segfault in PHP +Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=504634 diff --git a/Regression/bz504634-Sqlite-PRAGMA-user-version-causes-a-segfault-in/main.fmf b/Regression/bz504634-Sqlite-PRAGMA-user-version-causes-a-segfault-in/main.fmf new file mode 100644 index 0000000..307f91a --- /dev/null +++ b/Regression/bz504634-Sqlite-PRAGMA-user-version-causes-a-segfault-in/main.fmf @@ -0,0 +1,14 @@ +summary: Sanity test for sqlite database +description: '' +contact: Filip Janus +component: +- sqlite +path: /basic/ +framework: beakerlib +recommend: +- sqlite +duration: 10m +enabled: true +tag: +- Tier1 +- sqlite diff --git a/Regression/bz504634-Sqlite-PRAGMA-user-version-causes-a-segfault-in/runtest.sh b/Regression/bz504634-Sqlite-PRAGMA-user-version-causes-a-segfault-in/runtest.sh new file mode 100755 index 0000000..caea0e5 --- /dev/null +++ b/Regression/bz504634-Sqlite-PRAGMA-user-version-causes-a-segfault-in/runtest.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/sqlite/Regression/bz504634-Sqlite-PRAGMA-user-version-causes-a-segfault-in +# Description: Test for BZ#504634 (Sqlite "PRAGMA user_version" causes a segfault in) +# Author: Jan Scotka +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2012 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="sqlite" +COMMA=".headers on +PRAGMA user_version;" + +rlJournalStart + rlPhaseStartTest + rlRun "echo '$COMMA' | sqlite3 |grep 0" + rlRun "echo '$COMMA' | sqlite3 |grep user_version" + rlRun "echo '$COMMA' | sqlite3 |grep null" 1 + rlPhaseEnd + +rlJournalPrintText +rlJournalEnd diff --git a/basic/PURPOSE b/basic/PURPOSE new file mode 100644 index 0000000..e8394d1 --- /dev/null +++ b/basic/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/sqlite3/Sanity/basic +Description: Basic test for python and sqlite3 DB +Author: Branislav Nater diff --git a/basic/main.fmf b/basic/main.fmf new file mode 100644 index 0000000..dac28b6 --- /dev/null +++ b/basic/main.fmf @@ -0,0 +1,15 @@ +summary: Sanity test for sqlite database +description: '' +contact: Filip Janus +component: +- sqlite +path: /basic/ +framework: beakerlib +recommend: +- python36 +- sqlite +duration: 5m +enabled: true +tag: +- Tier1 +- sqlite diff --git a/basic/runtest.sh b/basic/runtest.sh new file mode 100755 index 0000000..a59e434 --- /dev/null +++ b/basic/runtest.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/sqlite3/Sanity/basic +# Description: Basic test for python and sqlite3 DB +# Author: Branislav Nater +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include beakerlib environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGES=${PACKAGE:-"python36 sqlite"} +PYTHON=${PYTHON:-python3} +REQUIRES=${REQUIRES:-sqlite} + +rlJournalStart + rlPhaseStartSetup + #rlAssertRpm --all + #rlAssertBinaryOrigin $PYTHON + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "cp sqlite3-test.py $TmpDir" 0 "Copy test script to $TmpDir" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlGetTestState && { + rlPhaseStartTest + rlRun "$PYTHON sqlite3-test.py" + rlPhaseEnd + } + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalEnd +rlJournalPrintText diff --git a/basic/sqlite3-test.py b/basic/sqlite3-test.py new file mode 100644 index 0000000..505ffc8 --- /dev/null +++ b/basic/sqlite3-test.py @@ -0,0 +1,37 @@ +#!/usr/bin/python + +import sqlite3 +import sys + +conn = None + +try: + conn = sqlite3.connect('test.db') + + cur = conn.cursor() + + cur.execute('SELECT SQLITE_VERSION()') + ver = cur.fetchone() + print("SQLite version: %s" % ver) + + # Create a new table 'Writers' + cur.execute("CREATE TABLE Writers(Id INTEGER PRIMARY KEY AUTOINCREMENT, \ + Name VARCHAR(25))") + cur.execute("INSERT INTO Writers(Name) VALUES('Jack London')") + cur.execute("INSERT INTO Writers(Name) VALUES('Honore de Balzac')") + cur.execute("INSERT INTO Writers(Name) VALUES('Lion Feuchtwanger')") + + # Retrieve data + for row in cur.execute("SELECT * FROM Writers"): + print(row) + + cur.execute("DROP TABLE Writers") + +except (sqlite3.Error) as e: + print("Error %s:" % e.args[0]) + sys.exit(1) + +finally: + + if conn: + conn.close() diff --git a/main.fmf b/main.fmf new file mode 100644 index 0000000..c5d1535 --- /dev/null +++ b/main.fmf @@ -0,0 +1,5 @@ +contact: Filip Janus +component: [sqlite] +test: ./runtest.sh +framework: beakerlib +tier: 1