Skip to content

Commit

Permalink
yast: Update tester and expected results
Browse files Browse the repository at this point in the history
Signed-off-by: Akshat Sikarwar <asikarwar1@bloomberg.net>
  • Loading branch information
akshatsikarwar committed Oct 26, 2023
1 parent fac6d21 commit 9280be7
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 24 deletions.
2 changes: 1 addition & 1 deletion tests/yast.test/runit
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ echo "logs at: $HOSTNAME:$TMPDIR"
RC=0
for test in `ls $FILE`;
do
echo -n "$test..."
echo "$test..."
tclsh $test $DB $FILEPATH $TCLCDB2 $CDB2_CONFIG
if [ "$?" == "0" ] ; then
echo_color " PASS" "green"
Expand Down
29 changes: 15 additions & 14 deletions tests/yast.test/subquery.test
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ do_test subquery-2.3.1 {
} {}
do_test subquery-2.3.2 {
execsql {
SELECT a IN (10.0, 20) FROM t3;
SELECT a IN (10.000000, 20) FROM t3;
}
} {0}
do_test subquery-2.3.3 {
Expand Down Expand Up @@ -289,6 +289,7 @@ ifcapable view {
# Ticket 1084
do_test subquery-3.2 {
catchsql {
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(a,b);
INSERT INTO t1 VALUES(1,2);
}
Expand All @@ -309,7 +310,7 @@ do_test subquery-3.3.1 {
do_test subquery-3.3.2 {
catchsql {DROP TABLE t2}
execsql {
CREATE TABLE t2(c, d);
CREATE TABLE t2(c, d text);
INSERT INTO t2 VALUES(1, 'one');
INSERT INTO t2 VALUES(2, 'two');
SELECT a, (SELECT d FROM t2 WHERE a=c) FROM t1 GROUP BY a;
Expand Down Expand Up @@ -347,7 +348,7 @@ do_test subquery-3.4.1 {
GROUP BY b.x
HAVING avg(a.y) > avg(b.y));
}
} {107 4.0}
} {107 4.000000}
do_test subquery-3.4.2 {
execsql {
SELECT a.x, avg(a.y) AS avg1
Expand All @@ -358,7 +359,7 @@ do_test subquery-3.4.2 {
GROUP BY b.x
HAVING avg1 > avg2);
}
} {107 4.0}
} {107 4.000000}
do_test subquery-3.4.3 {
execsql {
SELECT
Expand All @@ -376,15 +377,15 @@ do_test subquery-3.4.3 {
GROUP BY a.x
ORDER BY a.x;
}
} {106 4.5 0 1 107 4.0 1 0}
} {106 4.500000 0 1 107 4.000000 1 0}

do_test subquery-3.5.1 {
execsql {
CREATE TABLE t35a(x); INSERT INTO t35a VALUES(1),(2),(3);
CREATE TABLE t35b(y); INSERT INTO t35b VALUES(98), (99);
SELECT max((SELECT avg(y) FROM t35b)) FROM t35a;
}
} {98.5}
} {98.500000}
do_test subquery-3.5.2 {
execsql {
SELECT max((SELECT count(y) FROM t35b)) FROM t35a;
Expand Down Expand Up @@ -456,7 +457,7 @@ do_test subquery-4.2.2 {
# for a matching column name did not cause an otherwise static subquery
# to become a dynamic (correlated) subquery.
#
do_test subquery-5.1 {
comdb2_omit_test do_test subquery-5.1 {
proc callcntproc {n} {
incr ::callcnt
return $n
Expand All @@ -478,7 +479,7 @@ do_test subquery-5.1 {
(SELECT callcnt(y)+0 FROM t4 WHERE x="two")
}
} {22}
do_test subquery-5.2 {
comdb2_omit_test do_test subquery-5.2 {
# This is the key test. The subquery should have only run once. If
# The double-quoted identifier "two" were causing the subquery to be
# processed as a correlated subquery, then it would have run 4 times.
Expand All @@ -489,22 +490,22 @@ do_test subquery-5.2 {
# Ticket #1380. Make sure correlated subqueries on an IN clause work
# correctly when the left-hand side of the IN operator is constant.
#
do_test subquery-6.1 {
comdb2_omit_test do_test subquery-6.1 {
set callcnt 0
execsql {
SELECT x FROM t4 WHERE 1 IN (SELECT callcnt(count(*)) FROM t5 WHERE a=y)
}
} {one two three four}
do_test subquery-6.2 {
comdb2_omit_test do_test subquery-6.2 {
set callcnt
} {4}
do_test subquery-6.3 {
comdb2_omit_test do_test subquery-6.3 {
set callcnt 0
execsql {
SELECT x FROM t4 WHERE 1 IN (SELECT callcnt(count(*)) FROM t5 WHERE a=1)
}
} {one two three four}
do_test subquery-6.4 {
comdb2_omit_test do_test subquery-6.4 {
set callcnt
} {1}

Expand Down Expand Up @@ -599,7 +600,7 @@ do_execsql_test subquery-8.1 {
# from 2022-09-01.
#
reset_db
do_execsql_test subquery-10.1 {
comdb2_omit_test do_execsql_test subquery-10.1 {
CREATE TABLE t1(aa TEXT, bb INT, cc TEXT);
CREATE INDEX x11 on t1(bb);
CREATE INDEX x12 on t1(aa);
Expand All @@ -609,7 +610,7 @@ do_execsql_test subquery-10.1 {
INSERT INTO sqlite_stat1(tbl, idx, stat) VALUES('t1', 'x12', '156789 1');
ANALYZE sqlite_master;
}
do_eqp_test subquery-10.2 {
comdb2_omit_test do_eqp_test subquery-10.2 {
WITH v1(aa,cc,bb) AS (SELECT aa, cc, bb FROM t1 WHERE bb=12345),
v2(aa,mx) AS (SELECT aa, max(xx) FROM t2 GROUP BY aa)
SELECT * FROM v1 JOIN v2 ON v1.aa=v2.aa;
Expand Down
4 changes: 2 additions & 2 deletions tests/yast.test/subquery2.test
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ foreach {tn sql} {
#
reset_db
do_execsql_test 5.0 {
CREATE TABLE t1(x);
CREATE TABLE t1(x text);
INSERT INTO t1 VALUES('ALFKI');
INSERT INTO t1 VALUES('ANATR');

CREATE TABLE t2(y, z);
CREATE TABLE t2(y text, z text);
CREATE INDEX t2y ON t2 (y);
INSERT INTO t2 VALUES('ANATR', '1997-08-08 00:00:00');
INSERT INTO t2 VALUES('ALFKI', '1997-08-25 00:00:00');
Expand Down
35 changes: 28 additions & 7 deletions tests/yast.test/tester.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -856,22 +856,42 @@ proc do_test {name cmd expected} {
if {[catch {uplevel #0 "$cmd;\n"} result]} {
puts "\nError: $result $cmd"
fail_test $name
#AZ
flush stdout
#exit 1
} elseif {[regexp {^[~#]?/.*/$} $expected]} {
if {[string index $expected 0]=="~"} {
set re [string range $expected 2 end-1]
if {[string index $re 0]=="*"} {
# If the regular expression begins with * then treat it as a glob instead
set ok [string match $re $result]
} else {
set re [string map {# {[-0-9.]+}} $re]
set ok [regexp $re $result]
}
set ok [expr {!$ok}]
} else {
set re [string range $expected 1 end-1]
if {[string index $re 0]=="*"} {
# If the regular expression begins with * then treat it as a glob instead
set ok [string match $re $result]
} else {
set re [string map {# {[-0-9.]+}} $re]
set ok [regexp $re $result]
}
}
if { $ok == 1 } {
puts "Ok"
} else {
fail_test $name
}
} elseif {[string compare $result $expected]} {
puts "\nExpected: \[$expected\]\n Got: \[$result\]"
fail_test $name
#AZ
flush stdout
#exit 1
} else {
puts " Ok"
}
flush stdout
}

proc do_execsql_test {testname sql result} {
proc do_execsql_test {testname sql {result {}}} {
set r {}
foreach x $result {lappend r $x}
uplevel do_test $testname [list "execsql {$sql}"] [list $r]
Expand Down Expand Up @@ -1788,6 +1808,7 @@ proc ifcapable {expr code {else ""} {elsecode ""}} {
#regsub -all {[a-z_0-9]+} $expr {$::sqlite_options(&)} e2
#set e2 [fix_ifcapable_expr $expr]
switch $expr {
view -
update_delete_limit -
explain -
or_opt -
Expand Down
1 change: 1 addition & 0 deletions tests/yast.test/view.test
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ do_test view-1.0 {
do_test view-1.1 {
execsql {
#BEGIN;
DROP VIEW IF EXISTS v1;
CREATE VIEW IF NOT EXISTS v1 AS SELECT a,b FROM t1;
SELECT * FROM v1 ORDER BY a;
}
Expand Down

0 comments on commit 9280be7

Please sign in to comment.