From owner-freebsd-testing@FreeBSD.ORG Sun Mar 9 11:40:22 2014 Return-Path: Delivered-To: freebsd-testing@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0245C844 for ; Sun, 9 Mar 2014 11:40:22 +0000 (UTC) Received: from relay01.pair.com (relay01.pair.com [209.68.5.15]) by mx1.freebsd.org (Postfix) with SMTP id BCF67EC1 for ; Sun, 9 Mar 2014 11:40:21 +0000 (UTC) Received: (qmail 35476 invoked from network); 9 Mar 2014 11:40:13 -0000 Received: from 87.58.146.155 (HELO x2.osted.lan) (87.58.146.155) by relay01.pair.com with SMTP; 9 Mar 2014 11:40:13 -0000 X-pair-Authenticated: 87.58.146.155 Received: from x2.osted.lan (localhost [127.0.0.1]) by x2.osted.lan (8.14.5/8.14.5) with ESMTP id s29BeDcx057086; Sun, 9 Mar 2014 12:40:13 +0100 (CET) (envelope-from pho@x2.osted.lan) Received: (from pho@localhost) by x2.osted.lan (8.14.5/8.14.5/Submit) id s29BeDJo057085; Sun, 9 Mar 2014 12:40:13 +0100 (CET) (envelope-from pho) Date: Sun, 9 Mar 2014 12:40:12 +0100 From: Peter Holm To: Julio Merino Subject: Re: Test scenario for sysctl kern.maxfiles Message-ID: <20140309114012.GA54149@x2.osted.lan> References: <20140305085806.GA70478@x2.osted.lan> <20140306112322.GA10664@x2.osted.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: "freebsd-testing@freebsd.org" X-BeenThere: freebsd-testing@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Testing on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Mar 2014 11:40:22 -0000 On Thu, Mar 06, 2014 at 09:52:58AM -0500, Julio Merino wrote: > On Thu, Mar 6, 2014 at 6:23 AM, Peter Holm wrote: > > On Wed, Mar 05, 2014 at 10:08:49AM -0700, Alan Somers wrote: > >> On Wed, Mar 5, 2014 at 1:58 AM, Peter Holm wrote: > >> > Here's an attempt to verify that increasing kern.maxfiles works as > >> > expected. > >> > > >> > http://people.freebsd.org/~pho/kern_descrip_test-v3.diff > >> > -- > >> > Peter > > A couple of general comments: > > * In openfiles2(), it seems to me that 'i' should be size_t. That cast > in the for loop looks like a hack. > Done. > * Style detail: I'd change the code to say something like the > following, which clearly separates the action from the handling of the > result. > > r = open("/etc/passwd", O_RDONLY); > if (ignore) { > if (r == -1) > break; > } else { > ATF_REQUIRE(r != -1); > } > Rewritten. > * Why does this test rely on /etc/passwd? Just create a file in the > current directory and open it. See the atf_utils_* in the > atf-c-api(3) manpage for various helper functions to deal with files. > If you want to depend on system files, the test should be declaring > that explicitly with atf_set_md_var("require.files", "/etc/passwd"). > I mistakenly relied on numerous NetBSD examples that uses /etc/passwd. > * Does the period in the test case name kern.maxfiles__increase > actually work? I'm surprised. > It doesn't. > * What's the rationale behind the TEST macro? > Removed test code. > More below. > > >> 1) done should be of type "static volatile sig_atomic_t", not int, > >> because it's set by signal handlers. > >> > > > > Yes, that is nicer (I learned something new today :-). But the use > > here works because there is a call to usleep(3) after each test, > > forcing the compiler to reload the "done" variable. > > > >> 2) using atexit() to register a cleanup routing is a hack. No doubt > > > > Why do you say that using atexit(3) is a hack? > > Because that's not how cleanup should be implemented in atf tests: you > should be using the cleanup routines. The reason is that atexit(3) is > not guaranteed to work: if your test crashes or is killed by Kyua > because it overruns its deadline, your cleanup code won't work but a > cleanup routine will. > Skipped using atexit(3). > >> you already noticed that it's difficult to use Kyua's builtin cleanup > >> capabilities because of the need to pass the value of oldmaxfiles. I > >> too have experienced that frustration. Is there any way to pass > >> values from the body of a testcase to its cleanup? Using > >> atf_tc_set_md_var() would be one way, but the man page suggests that > >> that function cannot be called from the body. Julio, is there a > >> better way to do this? > > The "problem" is that the body and the cleanup run in different > processes really, so there is no way you can pass state other than > writing to a local file. > > This change: > > http://cvsweb.netbsd.org/bsdweb.cgi/src/tests/kernel/t_sysv.c.diff?r1=1.3&r2=1.4&only_with_tag=MAIN > > shows a way to do it. > > Because these tests are dealing with scary global system state (which > is a bad thing), I think that the hassle of having to do this cleanup > dance is "kinda justified": not that many tests should need it and, > for those that do, it becomes clear that maybe the test should be done > in a different way. > > We could do better, yes; I don't disagree with that. Suggestions? > > > Now this raises an interesting question for me: Which environment do > > you guys expect ATF to run in? If it is hosts like freefall, any > > resource hogging tests are out of the question I would think. > > That's the interesting question. This test will probably be flaky > and/or cause side-effects in the system while it runs because it > relies on state that is out of control of the test. > > For the setup at kyua1.nyi.freebsd.org, this is not a problem because > the tests run in a VM. But we want to encourage users to run the > tests themselves and this kind of tests may be problematic. > > Here goes a possibility: add a configuration variable > "allow_kernel_side_effects" or similar to kyua.conf > (test_suites.FreeBSD.allow_kernel_side_effects = true). Then make the > test case require the variable with atf_set_md_var("require.config", > "allow_kernel_side_effects") so that this test only runs when the user > has told Kyua to allow these tests. We can later change the > kyua1.nyi.freebsd.org setup to define this variable but we leave it > off by default for end users. Updated dif: http://people.freebsd.org/~pho/kern_descrip_test-v4.diff -- Peter