1
0
mirror of https://github.com/sqlite/sqlite.git synced 2026-10-23 21:49:02 +03:00
Files
sqlite/test/shellB.test
drh e892084680 In the CLI, disallow any use of the fileio extension in --safe mode.
[bugs:/info/2026-10-10T13:15:05Z|Bug 2026-10-10T13:15:05Z]

FossilOrigin-Name: e3e5ef4e17373677e1cc589ac79e20f6fb523e60fe8afdbc0b92f12cc75cff8b
2026-10-10 18:40:16 +00:00

94 lines
2.6 KiB
Plaintext

# 2025-11-12
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# TESTRUNNER: shell
#
# Test cases for the command-line shell using the newly renovated
# ".testcase" and ".check" commands.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set CLI [test_cli_invocation]
# Run an instance of the CLI on the file $name.
# Capture the number of test cases and the number of
# errors and increment the counts.
#
proc do_clitest {name args} {
set mapping [list <NAME> $::testdir/$name <CLI> $::CLI <ARGS> $args]
set script [string map $mapping {
catch {exec <CLI> <ARGS> :memory: <NAME> 2>@stdout} res
set ntest 0
set nerr 999
regexp {(\d+) tests? run with (\d+) errors?} $res all ntest nerr
set_test_counter count [expr {[set_test_counter count]+$ntest-1}]
set_test_counter errors [expr {[set_test_counter errors]+$nerr}]
if {$nerr==0} {set res "error count: 0"}
set res
}]
# puts $script
do_test shellB-$name $script {error count: 0}
}
# Attempt to build a loadable extension named $ext from source
# file $srcfile. Return true on success.
#
proc build_loadable {ext srcfile} {
if {$::tcl_platform(os) eq "Windows NT"} {
set ext [file root $ext].dll
set cmd [list exec gcc -shared -fPIC -I. -I.. -o $ext $srcfile]
} elseif {$::tcl_platform(os) eq "Darwin"} {
set ext [file root $ext].dylib
set cmd [list exec clang -dynamiclib -I. -I.. -o $ext $srcfile]
} else {
set ext [file root $ext].so
set cmd [list exec gcc -shared -fPIC -I. -I.. -o $ext $srcfile]
}
if {[catch $cmd msg]} {
# puts "Unable to build $ext, $msg"
return 0
} else {
return 1
}
}
do_clitest modeA.sql
do_clitest dblwidth-a.sql
do_clitest vt100-a.sql
do_clitest regexp1.sql
do_clitest imposter1.sql
do_clitest sha1.sql
do_clitest complete_sql.sql
do_clitest clierrors.sql
set probe $testdir/probe.txt
forcedelete $probe
set f [open $probe wb]
puts -nonewline $f xyzzy
close $f
do_clitest safemode.sql --safe
ifcapable vtab {
do_clitest dotcmd01.sql
do_clitest import01.sql
do_clitest intck01.sql --unsafe-testing
}
do_clitest fptest01.sql
unset -nocomplain ::env(SQLITE_PS1)
unset -nocomplain ::env(SQLITE_PS2)
do_clitest shell-prompt.sql
ifcapable vtab&load_ext {
set srcfile [file dir $testdir]/ext/misc/fossildelta.c
if {[build_loadable fossildelta $srcfile]} {
do_clitest fossildelta.sql
}
}
finish_test