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 (c) 2016 by Delphix. All rights reserved. 15# 16 17. $STF_SUITE/tests/functional/channel_program/channel_common.kshlib 18 19 20# 21# DESCRIPTION: 22# Passing memory limit options to channel programs should work correctly. 23# Programs that exceed these limits should fail gracefully. 24 25 26verify_runnable "global" 27 28log_mustnot_checkerror_program "Memory limit exhausted" \ 29 -t 100000000 $TESTPOOL - <<-EOF 30 a = {}; 31 i = 0; 32 while true do 33 i = i + 1 34 a[i] = "Here is the " .. i .. "th entry of a" 35 end; 36 return a 37EOF 38 39log_assert "memory limit options work" 40log_mustnot_checkerror_program "Memory limit exhausted" \ 41 -m 100000 -t 100000000 $TESTPOOL - <<-EOF 42 a = {}; 43 i = 0; 44 while true do 45 i = i + 1 46 a[i] = "Here is the " .. i .. "th entry of a" 47 end; 48 return a 49EOF 50 51log_must_program -m 100000 $TESTPOOL - <<-EOF 52 s = "teststring" 53 s = s .. s .. s .. s 54 return s 55EOF 56 57log_assert "very small memory limits fail correctly" 58log_mustnot_checkerror_program "Memory limit exhausted" -m 1 $TESTPOOL - <<-EOF 59 s = "teststring" 60 s = s .. s .. s .. s 61 return s 62EOF 63 64# Set the memlimit, in case it is a non-default value 65log_must set_tunable32 LUA_MAX_MEMLIMIT 100000000 66 67log_mustnot_checkerror_program "Invalid instruction or memory limit" \ 68 -m 200000000 $TESTPOOL - <<-EOF 69 return 1; 70EOF 71 72log_mustnot_checkerror_program "Return value too large" \ 73 -m 9223372036854775808 $TESTPOOL - <<-EOF 74 return 1; 75EOF 76 77log_pass "Memory limits work correctly." 78