Mir

Merge lp:~hikiko/mir/mir.1238000 into lp:mir

Proposed by Eleni Maria Stea
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 1134
Proposed branch: lp:~hikiko/mir/mir.1238000
Merge into: lp:mir
Diff against target: 19 lines (+2/-0)
1 file modified
tests/unit-tests/graphics/gbm/test_gbm_buffer_allocator.cpp (+2/-0)
To merge this branch: bzr merge lp:~hikiko/mir/mir.1238000
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
PS Jenkins bot (community) continuous-integration Approve
Kevin DuBois (community) Approve
Alexandros Frantzis (community) Needs Fixing
Review via email: mp+190922@code.launchpad.net

Commit message

Test GBMBufferAllocatorTest.bypass_disables_via_environment overrides the MIR_BYPASS env variable, causing other tests that use the MIR_BYPASS to fail when we run the unit-tests with --gtest_repeat=N, N>1. Set back the MIR_BYPASS env. var.

Description of the change

Test GBMBufferAllocatorTest.bypass_disables_via_environment overrides the MIR_BYPASS env variable, causing other tests that use the MIR_BYPASS to fail when we run the unit-tests with --gtest_repeat=N, N>1. Set back the MIR_BYPASS env. var.

To post a comment you must log in.
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

8 + setenv("MIR_BYPASS", "1", 1);

This also changes the test environment. The tests implicitly assume that MIR_BYPASS is unset, so let's make the assumption explicit by unsetting it for every test in SetUp.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Eleni Maria Stea (hikiko) wrote :

I unset it in both places because if a test runs after the bypass_disables_via_environment unit test but before the new setup, it might fail.

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> I unset it in both places because if a test runs after the bypass_disables_via_environment unit
> test but before the new setup, it might fail.

I don't think that's needed; SetUp() is run before every test is executed. From the googletest FAQ:

"The first thing to remember is that Google Test does not reuse the same test fixture object across multiple tests. For each TEST_F, Google Test will create a fresh test fixture object, immediately call SetUp(), run the test, call TearDown(), and then immediately delete the test fixture object."

Revision history for this message
Kevin DuBois (kdub) wrote :

yes, lets rm ln 16. looks okay after that (I'll pre-approve, based on removing the second unsetenv)

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> I unset it in both places because if a test runs after the bypass_disables_ via_environment unit test but before the new setup, it might fail.

Actually, on second thought, you make a valid point here since we are allowed to run tests (including ones from other test cases) in an arbitrary order, although we don't do so normally. In light of this, let's just keep the second unsetenv (end of the test). Ideally that should happen automatically when we leave the test function scope (using a wrapper class to set/unset the env, ala RAII), to ensure unsetenv gets called even in case an ASSERT fails.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I like keeping both unsets.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/unit-tests/graphics/gbm/test_gbm_buffer_allocator.cpp'
2--- tests/unit-tests/graphics/gbm/test_gbm_buffer_allocator.cpp 2013-09-18 14:41:59 +0000
3+++ tests/unit-tests/graphics/gbm/test_gbm_buffer_allocator.cpp 2013-10-14 13:41:47 +0000
4@@ -51,6 +51,7 @@
5 virtual void SetUp()
6 {
7 using namespace testing;
8+ unsetenv("MIR_BYPASS");
9
10 fake_devices.add_standard_drm_devices();
11
12@@ -154,6 +155,7 @@
13 auto buf = alloc.alloc_buffer(properties);
14 ASSERT_TRUE(buf.get() != NULL);
15 EXPECT_FALSE(buf->can_bypass());
16+ unsetenv("MIR_BYPASS");
17 }
18
19 TEST_F(GBMBufferAllocatorTest, correct_buffer_format_translation_argb_8888)

Subscribers

People subscribed via source and target branches