aboutsummaryrefslogtreecommitdiff
path: root/tests/zfs-pre-snapshot/fake-zfs
blob: 508c0f3ee622c096d580033cfcccef008c046bc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/sh
# Fake zfs for the zfs-pre-snapshot unit test. `snapshot` and `destroy` are
# logged (FAKE_ZFS_LOG); `list` prints a fixture snapshot set (FAKE_ZFS_SNAPSHOTS).
# Set FAKE_ZFS_SNAPSHOT_FAIL to make snapshot creation fail.
case "$1" in
    snapshot)
        [ -n "$FAKE_ZFS_SNAPSHOT_FAIL" ] && exit 1
        echo "snapshot $2" >> "$FAKE_ZFS_LOG"; exit 0 ;;
    destroy)
        echo "destroy $2" >> "$FAKE_ZFS_LOG"; exit 0 ;;
    list)
        cat "$FAKE_ZFS_SNAPSHOTS" 2>/dev/null; exit 0 ;;
esac
exit 0