{"thread":{"id":"38420","subject":"[BUG?] setting ulimit in test suite broken for me","startedAt":"2015-01-21T18:59:06Z","lastAt":"2015-01-22T00:54:18Z","messageCount":3,"participants":["Stefan Beller","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"255003","messageId":"1421866746-29444-1-git-send-email-sbeller@google.com","threadId":"38420","inReplyTo":null,"subject":"[BUG?] setting ulimit in test suite broken for me","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2015-01-21T18:59:06Z","receivedAt":"2015-01-21T18:59:06Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"Hi,\n\nso I wanted to create a new test for large transactions, which should look like:\n\n\trun_with_limited_open_files () {\n\t\t(ulimit -n 64 && \"$@\")\n\t}\n\n\ttest_lazy_prereq ULIMIT 'run_with_limited_open_files true'\n\n\ttest_expect_success ULIMIT 'large transaction creating branches does not burst open file limit' '\n\t(\n\t\techo $(ulimit -n)\n\t\tfor i in $(seq 65)\n\t\tdo\n\t\t\techo \"create refs/heads/$i HEAD\"\n\t\tdone >large_input &&\n\t\tgit update-ref --stdin <large_input &&\n\t\tgit rev-parse --verify -q refs/heads/65\n\t)\n\t'\n\nMind the \"echo $(ulimit -n)\" in there as a debugging output.\nSo if I run the test with \"-d -v\" to actually see the debugging output,\nI see ulimit -n set to 32768 instead of the desired 64.\n\nSo I assumed I made a mistake and looked at other places with a similar\npattern such as in t7004-tag.sh. Inserting a debug statement (as attached,\nso I don't need (to trust) -d and -v as parameters for the test) in there\nalso doesn't report the desired stack size of 128, but rather the system\ndefault of 8192. Is that just my system or does anybody else also run into\nsuch a problem?\n\nRunning ulimit -{n,s} manually in a shell (/bin/sh) as well as bash does\nwork as expected as it correctly reports with ulimit -a as well as breaking\nthe tests I try to write.\n\nThanks,\nStefan\n\nSigned-off-by: Stefan Beller <sbeller@google.com>\n---\n t/t7004-tag.sh | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/t/t7004-tag.sh b/t/t7004-tag.sh\nindex 35c805a..4f09cb4 100755\n--- a/t/t7004-tag.sh\n+++ b/t/t7004-tag.sh\n@@ -1460,20 +1460,21 @@ test_expect_success 'invalid sort parameter in configuratoin' '\n '\n \n run_with_limited_stack () {\n \t(ulimit -s 128 && \"$@\")\n }\n \n test_lazy_prereq ULIMIT 'run_with_limited_stack true'\n \n # we require ulimit, this excludes Windows\n test_expect_success ULIMIT '--contains works in a deep repo' '\n+\techo $(ulimit -s) > ../ulimit_recorded\n \t>expect &&\n \ti=1 &&\n \twhile test $i -lt 8000\n \tdo\n \t\techo \"commit refs/heads/master\n committer A U Thor <author@example.com> $((1000000000 + $i * 100)) +0200\n data <<EOF\n commit #$i\n EOF\"\n \t\ttest $i = 1 && echo \"from refs/heads/master^0\"\n-- \n2.2.1.62.g3f15098\n"},{"id":"255006","messageId":"20150121190348.GA29891@peff.net","threadId":"38420","inReplyTo":"1421866746-29444-1-git-send-email-sbeller@google.com","subject":"Re: [BUG?] setting ulimit in test suite broken for me","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2015-01-21T19:03:49Z","receivedAt":"2015-01-21T19:03:49Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Jan 21, 2015 at 10:59:06AM -0800, Stefan Beller wrote:\n\n> so I wanted to create a new test for large transactions, which should look like:\n> \n> \trun_with_limited_open_files () {\n> \t\t(ulimit -n 64 && \"$@\")\n> \t}\n> \n> \ttest_lazy_prereq ULIMIT 'run_with_limited_open_files true'\n> \n> \ttest_expect_success ULIMIT 'large transaction creating branches does not burst open file limit' '\n> \t(\n> \t\techo $(ulimit -n)\n> \t\tfor i in $(seq 65)\n> \t\tdo\n> \t\t\techo \"create refs/heads/$i HEAD\"\n> \t\tdone >large_input &&\n> \t\tgit update-ref --stdin <large_input &&\n> \t\tgit rev-parse --verify -q refs/heads/65\n> \t)\n> \t'\n> \n> Mind the \"echo $(ulimit -n)\" in there as a debugging output.\n> So if I run the test with \"-d -v\" to actually see the debugging output,\n> I see ulimit -n set to 32768 instead of the desired 64.\n\nYou define run_with_limited_open_files, which starts a subshell, drops\nthe limit inside the subshell, and then spawns the child. But you never\ncall it in the test. Were you expecting that tests with the ULIMIT\nprereq to automatically respect the limit? The prereq is just about\nchecking whether we can set the ulimit at all.\n\nTry:\n\n  run_with_limited_open_files ulimit -n\n\nin your debugging statement (and of course use run_with... for the\nactual git command you want to limit).\n\n-Peff\n"},{"id":"255052","messageId":"CAGZ79kZTZfFg2GUNCeML8_wcL42egkpjp+1VTNVBb7UAMdf7YA@mail.gmail.com","threadId":"38420","inReplyTo":"20150121190348.GA29891@peff.net","subject":"Re: [BUG?] setting ulimit in test suite broken for me","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2015-01-22T00:54:18Z","receivedAt":"2015-01-22T00:54:18Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Wed, Jan 21, 2015 at 11:03 AM, Jeff King <peff@peff.net> wrote:\n>\n> in your debugging statement (and of course use run_with... for the\n> actual git command you want to limit).\n>\n\nThanks for that hint, its now part of the bugfix series.\n\nStefan\n"}]}