[bind10-dev] failed test -- trunk r2675
Jelte Jansen
jelte at isc.org
Tue Aug 10 09:57:37 UTC 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 08/10/2010 01:32 AM, JINMEI Tatuya / 神明達哉 wrote:
> At Mon, 9 Aug 2010 23:12:34 +0000 (UTC),
> tester at isc.org (BIND 10 Tests) wrote:
>>
>> http://bind10.isc.org/~tester/2010/08/20100809230116-2675/make-coverage.out
>
> Environment variable "USER" doesn't seem to be defined in the auto
> test environment. The patch below should fix the problem (the patch
> also adds a test for a numeric user ID). This should be quite
> trivial, but I'd like to get it reviewed if it can be done quickly.
> Could someone check it?
>
ack, looks ok & works for me
(btw the failed test -- trunk r2681 mail is the same problem)
Jelte
> ---
> JINMEI, Tatuya
>
> Index: change_user_unittest.cc
> ===================================================================
> --- change_user_unittest.cc (revision 2675)
> +++ change_user_unittest.cc (working copy)
> @@ -19,6 +19,8 @@
>
> #include <string>
>
> +#include <boost/lexical_cast.hpp>
> +
> #include <gtest/gtest.h>
>
> #include <auth/common.h>
> @@ -27,28 +29,34 @@
> using namespace std;
>
> namespace {
> -class ChangeUserTest : public ::testing::Test {
> -protected:
> +TEST(ChangeUserTest, changeToTheSameUser) {
> + const char* const my_username = getenv("USER");
> +
> // normally the USER environment variable should be set to the name
> - // of the local user running this test. If we encounter a case where
> - // this doesn't hold, we'll need to add a prerequisite check in each
> - // test. For now we assume this is valid for simplicity.
> - ChangeUserTest() : my_username(getenv("USER")) {}
> - const string my_username;
> -};
> + // of the local user running this test, but it's not always the case.
> + if (my_username == NULL) {
> + cerr << "Environment variable USER is undefined, skipping the test"
> + << endl;
> + return;
> + }
>
> -TEST_F(ChangeUserTest, changeToTheSameUser) {
> // changing to the run time user should succeed.
> - EXPECT_NO_THROW(changeUser(my_username.c_str()));
> + EXPECT_NO_THROW(changeUser(my_username));
> }
>
> -TEST_F(ChangeUserTest, badUID) {
> +TEST(ChangeUserTest, changeToTheSameUserId) {
> + // same as above, but using numeric user ID
> + EXPECT_NO_THROW(changeUser(
> + (boost::lexical_cast<string>(getuid())).c_str()));
> +}
> +
> +TEST(ChangeUserTest, badUID) {
> // -1 should be an invalid numeric UID, and (hopefully) shouldn't be
> // a valid textual username.
> EXPECT_THROW(changeUser("-1"), FatalError);
> }
>
> -TEST_F(ChangeUserTest, promotionAttempt) {
> +TEST(ChangeUserTest, promotionAttempt) {
> // change to root should fail unless the running user is a super user.
> if (getuid() == 0) {
> cerr << "Already a super user, skipping the test" << endl;
> _______________________________________________
> bind10-dev mailing list
> bind10-dev at lists.isc.org
> https://lists.isc.org/mailman/listinfo/bind10-dev
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkxhIpEACgkQ4nZCKsdOncVbtQCgk69sFfa5YP1HElfvOuqp2KAC
gbQAnjNh5DDq0+rLSxrK4n3qjzY/xltm
=IWmW
-----END PGP SIGNATURE-----
More information about the bind10-dev
mailing list