smoke test: preliminary sqlite tests
This commit is contained in:
@@ -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()
|
||||
|
||||
10
var/spack/repos/builtin/packages/sqlite/test/dump.out
Normal file
10
var/spack/repos/builtin/packages/sqlite/test/dump.out
Normal file
@@ -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;
|
||||
BIN
var/spack/repos/builtin/packages/sqlite/test/packages.db
Normal file
BIN
var/spack/repos/builtin/packages/sqlite/test/packages.db
Normal file
Binary file not shown.
Reference in New Issue
Block a user