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, 2017 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: Returning very large (up to the memory limit) lists should
21eda14cbcSMatt Macy# function correctly.
22eda14cbcSMatt Macy#
23eda14cbcSMatt Macy
24eda14cbcSMatt Macyverify_runnable "global"
25eda14cbcSMatt Macy
26eda14cbcSMatt Macyfs=$TESTPOOL/$TESTFS/testchild
27eda14cbcSMatt Macy
28eda14cbcSMatt Macyfunction cleanup
29eda14cbcSMatt Macy{
3081b22a98SMartin Matuska	datasetexists $fs && destroy_dataset $fs -R
31eda14cbcSMatt Macy}
32eda14cbcSMatt Macy
33eda14cbcSMatt Macylog_onexit cleanup
34eda14cbcSMatt Macy
35eda14cbcSMatt Macylog_must zfs create $fs
36eda14cbcSMatt Macy
37eda14cbcSMatt Macy#
38eda14cbcSMatt Macy# Actually checking in the ~500kb expected result of this program would be
39eda14cbcSMatt Macy# awful, so we just make sure it was as long as we expected.
40eda14cbcSMatt Macy#
41eda14cbcSMatt Macyoutput_lines=$(log_must zfs program $TESTPOOL \
42eda14cbcSMatt Macy    $ZCP_ROOT/lua_core/tst.return_large.zcp | wc -l)
43eda14cbcSMatt Macy
44*716fd348SMartin Matuskalog_must [ $output_lines -ge 5000 ]
45eda14cbcSMatt Macy
46eda14cbcSMatt Macy#
47eda14cbcSMatt Macy# Make sure we fail if the return is over the memory limit
48eda14cbcSMatt Macy#
49eda14cbcSMatt Macylog_mustnot_program -m 10000 $TESTPOOL \
50eda14cbcSMatt Macy    $ZCP_ROOT/lua_core/tst.return_large.zcp
51eda14cbcSMatt Macy
52eda14cbcSMatt Macylog_pass "Large return values work properly"
53eda14cbcSMatt Macy
54