1eda14cbcSMatt Macy#!/bin/ksh -p 2eda14cbcSMatt Macy# 3eda14cbcSMatt Macy# This file and its contents are supplied under the terms of the 4eda14cbcSMatt Macy# Common Development and Distribution License ("CDDL"), version 1.0. 5eda14cbcSMatt Macy# You may only use this file in accordance with the terms of version 6eda14cbcSMatt Macy# 1.0 of the CDDL. 7eda14cbcSMatt Macy# 8eda14cbcSMatt Macy# A full copy of the text of the CDDL should have accompanied this 9eda14cbcSMatt Macy# source. A copy of the CDDL is also available via the Internet at 10eda14cbcSMatt Macy# http://www.illumos.org/license/CDDL. 11eda14cbcSMatt Macy# 12eda14cbcSMatt Macy 13eda14cbcSMatt Macy# 14eda14cbcSMatt Macy# Copyright (c) 2016 by Delphix. All rights reserved. 15eda14cbcSMatt Macy# 16eda14cbcSMatt Macy 17eda14cbcSMatt Macy. $STF_SUITE/tests/functional/channel_program/channel_common.kshlib 18eda14cbcSMatt Macy 19eda14cbcSMatt Macy# 20eda14cbcSMatt Macy# DESCRIPTION: 21eda14cbcSMatt Macy# Try returning various values that lua allows you to construct, 22eda14cbcSMatt Macy# but that cannot be represented as nvlists and therefore should 23eda14cbcSMatt Macy# cause the script to fail (but not panic). Try sending the values 24eda14cbcSMatt Macy# back to userland from both "return" and "error()". 25eda14cbcSMatt Macy# 26eda14cbcSMatt Macy 27eda14cbcSMatt Macyverify_runnable "both" 28eda14cbcSMatt Macy 29eda14cbcSMatt Macyset -A args 'function() return 1 end' \ 30eda14cbcSMatt Macy '{[{}]=true}' \ 31eda14cbcSMatt Macy '{[function() return 1 end]=0}' \ 32eda14cbcSMatt Macy 'assert' \ 33eda14cbcSMatt Macy '0, assert' \ 34eda14cbcSMatt Macy 'true, {[{}]=0}' \ 35eda14cbcSMatt Macy '{val=true}, {val=false}' \ 36eda14cbcSMatt Macy '{1, 2, 3}, {[4]=5}' \ 37eda14cbcSMatt Macy 'nil, true, 1, "test", {}, {val=true}' \ 38eda14cbcSMatt Macy '{[false]=true, ["false"]=false}' \ 39eda14cbcSMatt Macy '{[true]=false, ["true"]=true}' \ 40eda14cbcSMatt Macy '{[0]=true, ["0"]=false}' \ 41eda14cbcSMatt Macy '{0,0,0,["1"]=0}' \ 42eda14cbcSMatt Macy '{0,0,0,["2"]=0}' \ 43eda14cbcSMatt Macy '{0,0,0,["3"]=0}' 44eda14cbcSMatt Macy 45eda14cbcSMatt Macytypeset -i last_index=$((${#args[*]} - 1)) 46eda14cbcSMatt Macyfor i in $(seq 0 $last_index); do 47eda14cbcSMatt Macy log_note "running program: ${args[i]}" 48*716fd348SMartin Matuska log_mustnot_checkerror_program "execution failed" $TESTPOOL - <<<"return ${args[i]}" 49eda14cbcSMatt Macy ((i = i + 1)) 50eda14cbcSMatt Macydone 51eda14cbcSMatt Macy 52eda14cbcSMatt Macyfor i in $(seq 0 $last_index); do 53eda14cbcSMatt Macy log_note "running program: ${args[i]}" 54*716fd348SMartin Matuska log_mustnot_checkerror_program "execution failed" $TESTPOOL - <<<"error(${args[i]})" 55eda14cbcSMatt Macy ((i = i + 1)) 56eda14cbcSMatt Macydone 57eda14cbcSMatt Macy 58eda14cbcSMatt Macylog_pass "Returning lua constructs that cannot be converted to " \ 59eda14cbcSMatt Macy "nvlists fails as expected." 60