From 0b8bc43fb0fe83ea61b24e15b3a16b5c86f995d1 Mon Sep 17 00:00:00 2001 From: Tamara Dahlgren Date: Thu, 30 Jul 2020 19:06:28 -0700 Subject: [PATCH] smoke test: preliminary sqlite tests --- .../repos/builtin/packages/sqlite/package.py | 49 ++++++++++++++++++ .../builtin/packages/sqlite/test/dump.out | 10 ++++ .../builtin/packages/sqlite/test/packages.db | Bin 0 -> 3072 bytes 3 files changed, 59 insertions(+) create mode 100644 var/spack/repos/builtin/packages/sqlite/test/dump.out create mode 100644 var/spack/repos/builtin/packages/sqlite/test/packages.db diff --git a/var/spack/repos/builtin/packages/sqlite/package.py b/var/spack/repos/builtin/packages/sqlite/package.py index b400965b3f0..d753788814e 100644 --- a/var/spack/repos/builtin/packages/sqlite/package.py +++ b/var/spack/repos/builtin/packages/sqlite/package.py @@ -3,10 +3,21 @@ # # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import llnl.util.tty as tty +import re + from spack import * from spack import architecture +def _get_output(filename): + """Read and clean up the expected output from the specified file.""" + output = '' + with open('./data/{0}'.format(filename), 'r') as fd: + output = fd.read() + return [re.escape(ln) for ln in output.split('\n')] + + class Sqlite(AutotoolsPackage): """SQLite3 is an SQL database engine in a C library. Programs that link the SQLite3 library can have SQL database access without @@ -129,3 +140,41 @@ def build_libsqlitefunctions(self): cc(self.compiler.cc_pic_flag, '-lm', '-shared', 'extension-functions.c', '-o', libraryname) install(libraryname, self.prefix.lib) + + def _test_example(self): + """Ensure a sequence of commands on example db are successful.""" + + # Ensure the database only contains one table + reason = 'test to ensure only table is "packages"' + opts = ['./data/packages.db', '.tables'] + self.run_test('sqlite3', opts, 'packages', None, installed=True, + purpose=reason, skip_missing=False) + + # Ensure the database dump matches expectations, where special + # characters are replaced with spaces in the expected and actual + # output to avoid pattern errors. + reason = 'test dump output' + opts = ['./data/packages.db', '.dump'] + expected = _get_output('dump.out') + self.run_test('sqlite3', opts, expected, None, installed=True, + purpose=reason, skip_missing=False) + + def _test_version(self): + """Perform version check on the installed package.""" + exe = 'sqlite3' + vers_str = str(self.spec.version) + + reason = 'test version of {0} is {1}'.format(exe, vers_str) + self.run_test(exe, '-version', vers_str, None, installed=True, + purpose=reason, skip_missing=False) + + def test(self): + """Perform smoke tests on the installed package.""" + tty.debug('Expected results currently based on simple {0} builds' + .format(self.name)) + + # Perform a simple version check + self._test_version() + + # Run a sequence of operations + self._test_example() diff --git a/var/spack/repos/builtin/packages/sqlite/test/dump.out b/var/spack/repos/builtin/packages/sqlite/test/dump.out new file mode 100644 index 00000000000..3dda19d1c5a --- /dev/null +++ b/var/spack/repos/builtin/packages/sqlite/test/dump.out @@ -0,0 +1,10 @@ +PRAGMA foreign_keys=OFF; +BEGIN TRANSACTION; +CREATE TABLE packages ( +name varchar(80) primary key, +has_code integer, +url varchar(160)); +INSERT INTO packages VALUES('sqlite',1,'https://www.sqlite.org'); +INSERT INTO packages VALUES('readline',1,'https://tiswww.case.edu/php/chet/readline/rltop.html'); +INSERT INTO packages VALUES('xsdk',0,'http://xsdk.info'); +COMMIT; diff --git a/var/spack/repos/builtin/packages/sqlite/test/packages.db b/var/spack/repos/builtin/packages/sqlite/test/packages.db new file mode 100644 index 0000000000000000000000000000000000000000..252962235c7091721a4bd63c1f58a436acb187cf GIT binary patch literal 3072 zcmeHHyH3L}6t#0BXd*gR&>@n?MrxB*NC;SHsk(K6c8^TrHc|7!abF{R2Y&*Wwt2}WiaPpBZLNJki>J|PH67a@>G0ZXUMDU|U(=&18% z*WnXsFhMYZ=Y0cJy<*^xGqA#k$Cia3t^~b{Sx)^0owGt&ZFoBxOh;roxE_y)%956u z(u9!}<$g$c>%41|oJR@eTe4u=wi(jG^Rs}FC>3nZc-vg^_@}*h*0pU{J2)O%7)5Eo zHpP7`_u8XNk$uOWddcf4uiS0DE-!#b1TXL;O@)eqih*Bc-~{wWt+OeDMJPmm>AI!s zMCmN+Yr17DIio=wrL3$LvMi!vyxWFZs?p`K$Z{tXNldWbG%j{p vpytcrUB=1y+?0O>ct!9IAJSB)7^oQdM-0@UflEPwBe1Yi2+e?|vD1Jr(GPo8 literal 0 HcmV?d00001