Changeset View
Changeset View
Standalone View
Standalone View
bin/sh/t_cmdsub.sh
Property | Old Value | New Value |
---|---|---|
File Mode | 100755 | 100644 |
# $NetBSD: t_cmdsub.sh,v 1.4 2016/04/04 12:40:13 christos Exp $ | # $NetBSD: t_cmdsub.sh,v 1.5 2017/06/16 07:37:41 kre Exp $ | ||||
# | # | ||||
# Copyright (c) 2016 The NetBSD Foundation, Inc. | # Copyright (c) 2016 The NetBSD Foundation, Inc. | ||||
# All rights reserved. | # All rights reserved. | ||||
# | # | ||||
# Redistribution and use in source and binary forms, with or without | # Redistribution and use in source and binary forms, with or without | ||||
# modification, are permitted provided that the following conditions | # modification, are permitted provided that the following conditions | ||||
# are met: | # are met: | ||||
# 1. Redistributions of source code must retain the above copyright | # 1. Redistributions of source code must retain the above copyright | ||||
▲ Show 20 Lines • Show All 663 Lines • ▼ Show 20 Lines | x_heredoc_outside_backticks_body() { | ||||
atf_check -s exit:0 -o inline:'A Calculation:\n17 / 3 = 5\n' -e empty \ | atf_check -s exit:0 -o inline:'A Calculation:\n17 / 3 = 5\n' -e empty \ | ||||
${TEST_SH} -c 'echo "` cat <<- EOF `" | ${TEST_SH} -c 'echo "` cat <<- EOF `" | ||||
A Calculation: | A Calculation: | ||||
17 / 3 = $(( 17 / 3 )) | 17 / 3 = $(( 17 / 3 )) | ||||
EOF | EOF | ||||
' | ' | ||||
} | } | ||||
atf_test_case t_nested_cmdsubs_in_heredoc | atf_test_case y_many_embedded_nl | ||||
t_nested_cmdsubs_in_heredoc_head() { | y_many_embedded_nl_head() { | ||||
atf_set "descr" "Checks nested command substitutions in here docs" | atf_set "descr" "Checks command substitutions that return many lines" | ||||
} | } | ||||
t_nested_cmdsubs_in_heredoc_body() { | y_many_embedded_nl_body() { | ||||
atf_require_prog cat | atf_require_prog wc | ||||
atf_require_prog rm | atf_require_prog seq | ||||
rm -f * 2>/dev/null || : | # first make sure it should work | ||||
echo "Hello" > File | atf_check -s exit:0 -o match:'1002' -e empty \ | ||||
${TEST_SH} -c "{ printf '%s\n' x | |||||
for a in \$( seq 1000 ); do printf '\n'; done | |||||
printf '%s\n' y; } | wc -l" | |||||
atf_check -s exit:0 -o inline:'Hello U\nHelp me!\n' -e empty \ | # then use a cmd-sub to get the same thing | ||||
${TEST_SH} -c 'cat <<- EOF | atf_check -s exit:0 -o match:'1002' -e empty \ | ||||
$(cat File) U | ${TEST_SH} -c "printf '%s\n' \"\$( printf '%s\n' x | ||||
$( V=$(cat File); echo "${V%lo}p" ) me! | for a in \$( seq 1000 ); do printf '\n'; done | ||||
EOF' | printf '%s\n' y )\" | wc -l" | ||||
rm -f * 2>/dev/null || : | # and a much bigger one. | ||||
echo V>V ; echo A>A; echo R>R | atf_check -s exit:0 -o match:'10002' -e empty \ | ||||
echo Value>VAR | ${TEST_SH} -c "printf '%s\n' \"\$( printf '%s\n' x | ||||
for a in \$( seq 10000 ); do printf '\n'; done | |||||
atf_check -s exit:0 -o inline:'$2.50\n' -e empty \ | printf '%s\n' y )\" | wc -l" | ||||
${TEST_SH} -c 'cat <<- EOF | |||||
$(Value='\''$2.50'\'';eval echo $(eval $(cat V)$(cat A)$(cat R)=\'\''\$$(cat $(cat V)$(cat A)$(cat R))\'\''; eval echo \$$(set -- *;echo ${3}${1}${2}))) | |||||
EOF' | |||||
} | } | ||||
atf_test_case z_absurd_heredoc_cmdsub_combos | atf_test_case z_absurd_heredoc_cmdsub_combos | ||||
z_absurd_heredoc_cmdsub_combos_head() { | z_absurd_heredoc_cmdsub_combos_head() { | ||||
atf_set "descr" "perverse and unusual cmd substitutions & more" | atf_set "descr" "perverse and unusual cmd substitutions & more" | ||||
} | } | ||||
z_absurd_heredoc_cmdsub_combos_body() { | z_absurd_heredoc_cmdsub_combos_body() { | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | atf_init_test_cases() { | ||||
atf_add_test_case q_backticks_in_heredoc | atf_add_test_case q_backticks_in_heredoc | ||||
atf_add_test_case r_heredoc_in_cmdsub | atf_add_test_case r_heredoc_in_cmdsub | ||||
atf_add_test_case s_heredoc_in_backticks | atf_add_test_case s_heredoc_in_backticks | ||||
atf_add_test_case t_nested_cmdsubs_in_heredoc | atf_add_test_case t_nested_cmdsubs_in_heredoc | ||||
atf_add_test_case u_nested_backticks_in_heredoc | atf_add_test_case u_nested_backticks_in_heredoc | ||||
atf_add_test_case v_cmdsub_paren_tests | atf_add_test_case v_cmdsub_paren_tests | ||||
atf_add_test_case w_heredoc_outside_cmdsub | atf_add_test_case w_heredoc_outside_cmdsub | ||||
atf_add_test_case x_heredoc_outside_backticks | atf_add_test_case x_heredoc_outside_backticks | ||||
atf_add_test_case y_many_embedded_nl | |||||
atf_add_test_case z_absurd_heredoc_cmdsub_combos | atf_add_test_case z_absurd_heredoc_cmdsub_combos | ||||
} | } |