Merge lp:~serge-hallyn/upstart/upstart-fix-cgm-env-tests into lp:upstart

Proposed by Serge Hallyn
Status: Merged
Merged at revision: 1659
Proposed branch: lp:~serge-hallyn/upstart/upstart-fix-cgm-env-tests
Merge into: lp:upstart
Diff against target: 82 lines (+34/-13)
2 files modified
test/test_util_common.c (+17/-7)
test/tests/test_util_check_env.c (+17/-6)
To merge this branch: bzr merge lp:~serge-hallyn/upstart/upstart-fix-cgm-env-tests
Reviewer Review Type Date Requested Status
James Hunt Approve
Review via email: mp+227976@code.launchpad.net

Description of the change

This allows 'make check' by an unprivileged user to succeed if they do not own their current cgroups.

The commit message forgets to point out that this also fixes segv bugs by cleaning up the NihErrors after failed cgmanager client calls.

To post a comment you must log in.
Revision history for this message
James Hunt (jamesodhunt) wrote :

Hi Serge,

Thanks for doing this. There is a small problem in that even on a correctly configured system, test_checks() still displays "Skipping CGManager tests, CGManager not properly configured".

A minimal fix may be something like the following:

=== modified file 'test/tests/test_util_check_env.c'
--- test/tests/test_util_check_env.c 2014-07-23 18:34:26 +0000
+++ test/tests/test_util_check_env.c 2014-07-24 07:39:49 +0000
@@ -190,7 +190,8 @@
        }
 out_skip:
        disconnect_cgmanager();
- nih_warn ("Skipping CGManager tests, CGManager not properly configured");
+ if (ret)
+ nih_warn ("Skipping CGManager tests, CGManager not properly configured");
 #endif /* ENABLE_CGROUPS */

 }

review: Needs Fixing
Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

Hah! Thanks, James. Updating that now.

1660. By Serge Hallyn

Don't warn about skipped tests if the tests were run and passed.

Thanks James.

Revision history for this message
James Hunt (jamesodhunt) wrote :

Thanks - merged!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'test/test_util_common.c'
--- test/test_util_common.c 2014-07-10 16:45:19 +0000
+++ test/test_util_common.c 2014-07-24 16:18:09 +0000
@@ -1468,21 +1468,31 @@
1468 *p = '\0';1468 *p = '\0';
1469 if (cgmanager_create_sync(NULL, cgroup_manager, line, cg,1469 if (cgmanager_create_sync(NULL, cgroup_manager, line, cg,
1470 &e) != 0) {1470 &e) != 0) {
1471 nih_error("%s: failed to create cgroup %s:%s",1471 NihError *nerr;
1472 __func__, line, cg);1472 nerr = nih_error_get();
1473 nih_error("%s: failed to create cgroup %s:%s: %s",
1474 __func__, line, cg, nerr->message);
1475 nih_free(nerr);
1473 goto out;1476 goto out;
1474 }1477 }
1475 if (e == 1)1478 if (e == 1)
1476 nih_warn("%s: boggle: cgroup %s:%s already existed",1479 nih_warn("%s: boggle: cgroup %s:%s already existed",
1477 __func__, line, cg);1480 __func__, line, cg);
1478 if (cgmanager_remove_on_empty_sync(NULL, cgroup_manager, line,1481 if (cgmanager_remove_on_empty_sync(NULL, cgroup_manager, line,
1479 cg) != 0)1482 cg) != 0) {
1480 nih_warn("%s: failed to mark %s:%s remove-on-empty",1483 NihError *nerr;
1481 __func__, line, cg);1484 nerr = nih_error_get();
1485 nih_warn("%s: failed to mark %s:%s remove-on-empty: %s",
1486 __func__, line, cg, nerr->message);
1487 nih_free(nerr);
1488 }
1482 if (cgmanager_move_pid_sync(NULL, cgroup_manager, line, cg,1489 if (cgmanager_move_pid_sync(NULL, cgroup_manager, line, cg,
1483 mypid) != 0) {1490 mypid) != 0) {
1484 nih_error("%s: failed to move myself to cgroup %s:%s",1491 NihError *nerr;
1485 __func__, line, cg);1492 nerr = nih_error_get();
1493 nih_error("%s: failed to move myself to cgroup %s:%s: %s",
1494 __func__, line, cg, nerr->message);
1495 nih_free(nerr);
1486 goto out;1496 goto out;
1487 }1497 }
1488 }1498 }
14891499
=== modified file 'test/tests/test_util_check_env.c'
--- test/tests/test_util_check_env.c 2014-06-05 12:53:33 +0000
+++ test/tests/test_util_check_env.c 2014-07-24 16:18:09 +0000
@@ -169,18 +169,29 @@
169 TEST_FEATURE ("checking for cgmanager");169 TEST_FEATURE ("checking for cgmanager");
170 ret = connect_to_cgmanager ();170 ret = connect_to_cgmanager ();
171 switch (ret) {171 switch (ret) {
172 case -2: TEST_FAILED ("Found no cgroup manager"); break;172 case -2:
173 case -1: TEST_FAILED ("Error connecting to cgmanager"); break;173 nih_warn ("Found no cgroup manager");
174 case 0: print_my_cgroup (); break;174 goto out_skip;
175 default: TEST_FAILED ("Unknown error from connect_to_cgmanager: %d", ret);175 case -1:
176 nih_warn ("Error connecting to cgmanager");
177 goto out_skip;
178 case 0:
179 print_my_cgroup ();
180 break;
181 default: nih_warn ("Unknown error from connect_to_cgmanager: %d", ret);
182 goto out_skip;
176 }183 }
177184
178 TEST_FEATURE ("cgroup sandbox");185 TEST_FEATURE ("cgroup sandbox");
179 TEST_EQ (check_cgroup_sandbox (), 0);186 if (check_cgroup_sandbox() != 0)
180 disconnect_cgmanager ();187 nih_warn ("Could not create cgroup sandbox");
181 } else {188 } else {
182 nih_warn ("Skipping CGManager tests, CGManager socket not found");189 nih_warn ("Skipping CGManager tests, CGManager socket not found");
183 }190 }
191out_skip:
192 disconnect_cgmanager();
193 if (ret)
194 nih_warn ("Skipping CGManager tests, CGManager not properly configured");
184#endif /* ENABLE_CGROUPS */195#endif /* ENABLE_CGROUPS */
185196
186}197}

Subscribers

People subscribed via source and target branches