]> git.proxmox.com Git - mirror_zfs.git/blob - tests/zfs-tests/tests/functional/pyzfs/pyzfs_unittest.ksh
pyzfs: python3 support (unit tests)
[mirror_zfs.git] / tests / zfs-tests / tests / functional / pyzfs / pyzfs_unittest.ksh
1 #!/bin/ksh -p
2 #
3 # This file and its contents are supplied under the terms of the
4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 # You may only use this file in accordance with the terms of version
6 # 1.0 of the CDDL.
7 #
8 # A full copy of the text of the CDDL should have accompanied this
9 # source. A copy of the CDDL is also available via the Internet at
10 # http://www.illumos.org/license/CDDL.
11 #
12
13 #
14 # Copyright 2018, loli10K <ezomori.nozomu@gmail.com>. All rights reserved.
15 #
16
17 . $STF_SUITE/include/libtest.shlib
18
19 #
20 # DESCRIPTION:
21 # Verify the libzfs_core Python test suite can be run successfully
22 #
23 # STRATEGY:
24 # 1. Run the nvlist and libzfs_core Python unittest
25 # 2. Verify the exit code is 0 (no errors)
26 #
27
28 verify_runnable "global"
29
30 # Verify that the required dependencies for testing are installed.
31 python -c "import cffi" 2>/dev/null
32 if [ $? -eq 1 ]; then
33 log_unsupported "python-cffi not found by Python"
34 fi
35
36 # We don't just try to "import libzfs_core" because we want to skip these tests
37 # only if pyzfs was not installed due to missing, build-time, dependencies; if
38 # we cannot load "libzfs_core" due to other reasons, for instance an API/ABI
39 # mismatch, we want to report it.
40 python -c '
41 import pkgutil, sys
42 sys.exit(pkgutil.find_loader("libzfs_core") is None)'
43 if [ $? -eq 1 ]; then
44 log_unsupported "libzfs_core not found by Python"
45 fi
46
47 log_assert "Verify the nvlist and libzfs_core Python unittest run successfully"
48
49 # NOTE: don't use log_must() here because it makes output unreadable
50 python -m unittest --verbose \
51 libzfs_core.test.test_nvlist.TestNVList \
52 libzfs_core.test.test_libzfs_core.ZFSTest
53 if [ $? -ne 0 ]; then
54 log_fail "Python unittest completed with errors"
55 fi
56
57 log_pass "Python unittest completed without errors"