Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e504d0be authored by Hugo Benichi's avatar Hugo Benichi Committed by android-build-merger
Browse files

Merge "Relax SharedLogTest asserts" am: 91464bfe am: 541079e0

am: a29861b0

Change-Id: I53d99edee6729b753707db251e252297b927d2a7
parents da3774ea a29861b0
Loading
Loading
Loading
Loading
+13 −15
Original line number Original line Diff line number Diff line
@@ -33,9 +33,8 @@ import java.util.Vector;
@RunWith(AndroidJUnit4.class)
@RunWith(AndroidJUnit4.class)
@SmallTest
@SmallTest
public class SharedLogTest {
public class SharedLogTest {
    private static final String TIMESTAMP_PATTERN =
    private static final String TIMESTAMP_PATTERN = "\\d{2}:\\d{2}:\\d{2}\\.\\d{3}";
            "^[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]";
    private static final String TIMESTAMP = "HH:MM:SS.xxx";
    private static final String TIMESTAMP = "mm-dd HH:MM:SS.xxx";


    @Test
    @Test
    public void testBasicOperation() {
    public void testBasicOperation() {
@@ -53,12 +52,12 @@ public class SharedLogTest {
        logLevel2a.mark("ok: last post");
        logLevel2a.mark("ok: last post");


        final String[] expected = {
        final String[] expected = {
            TIMESTAMP + " - MARK first post!",
            " - MARK first post!",
            TIMESTAMP + " - [twoB] ERROR 2b or not 2b",
            " - [twoB] ERROR 2b or not 2b",
            TIMESTAMP + " - [twoA] WARN second post?",
            " - [twoA] WARN second post?",
            TIMESTAMP + " - still logging",
            " - still logging",
            TIMESTAMP + " - [twoA.three] 3 >> 2",
            " - [twoA.three] 3 >> 2",
            TIMESTAMP + " - [twoA] MARK ok: last post",
            " - [twoA] MARK ok: last post",
        };
        };
        // Verify the logs are all there and in the correct order.
        // Verify the logs are all there and in the correct order.
        verifyLogLines(expected, logTop);
        verifyLogLines(expected, logTop);
@@ -82,13 +81,12 @@ public class SharedLogTest {
        final String[] lines = dumpOutput.split("\n");
        final String[] lines = dumpOutput.split("\n");
        assertEquals(expected.length, lines.length);
        assertEquals(expected.length, lines.length);


        for (int i = 0; i < lines.length; i++) {
            // Fix up the timestamps.
            lines[i] = lines[i].replaceAll(TIMESTAMP_PATTERN, TIMESTAMP);
        }

        for (int i = 0; i < expected.length; i++) {
        for (int i = 0; i < expected.length; i++) {
            assertEquals(expected[i], lines[i]);
            String got = lines[i];
            String want = expected[i];
            assertTrue(String.format("'%s' did not contain '%s'", got, want), got.endsWith(want));
            assertTrue(String.format("'%s' did not contain a HH:MM:SS.xxx timestamp", got),
                    got.replaceFirst(TIMESTAMP_PATTERN, TIMESTAMP).contains(TIMESTAMP));
        }
        }
    }
    }
}
}