]> git.proxmox.com Git - mirror_zfs.git/blame - 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
CommitLineData
85ce3f4f 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
28verify_runnable "global"
29
e4a3297a
BB
30# Verify that the required dependencies for testing are installed.
31python -c "import cffi" 2>/dev/null
32if [ $? -eq 1 ]; then
33 log_unsupported "python-cffi not found by Python"
34fi
35
85ce3f4f 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.
40python -c '
41import pkgutil, sys
42sys.exit(pkgutil.find_loader("libzfs_core") is None)'
e4a3297a 43if [ $? -eq 1 ]; then
85ce3f4f 44 log_unsupported "libzfs_core not found by Python"
45fi
46
47log_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
50python -m unittest --verbose \
51 libzfs_core.test.test_nvlist.TestNVList \
52 libzfs_core.test.test_libzfs_core.ZFSTest
53if [ $? -ne 0 ]; then
54 log_fail "Python unittest completed with errors"
55fi
56
57log_pass "Python unittest completed without errors"