Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: obsolete/breakpad/common/linux/file_id_unittest.cc

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2009, Google Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
13 // distribution.
14 // * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 // Unit tests for FileID
31
32 #include <stdlib.h>
33
34 #include "common/linux/file_id.h"
35 #include "breakpad_googletest_includes.h"
36
37 using namespace google_breakpad;
38
39
40 namespace {
41 typedef testing::Test FileIDTest;
42 }
43
44 TEST(FileIDTest, FileIDStrip) {
45 // Calculate the File ID of our binary using
46 // FileID::ElfFileIdentifier, then make a copy of our binary,
47 // strip it, and ensure that we still get the same result.
48 char exe_name[PATH_MAX];
49 ssize_t len = readlink("/proc/self/exe", exe_name, PATH_MAX - 1);
50 ASSERT_NE(len, -1);
51 exe_name[len] = '\0';
52
53 // copy our binary to a temp file, and strip it
54 char templ[] = "/tmp/file-id-unittest-XXXXXX";
55 mktemp(templ);
56 char cmdline[4096];
57 sprintf(cmdline, "cp \"%s\" \"%s\"", exe_name, templ);
58 ASSERT_EQ(system(cmdline), 0);
59 sprintf(cmdline, "strip \"%s\"", templ);
60 ASSERT_EQ(system(cmdline), 0);
61
62 uint8_t identifier1[sizeof(MDGUID)];
63 uint8_t identifier2[sizeof(MDGUID)];
64 FileID fileid1(exe_name);
65 EXPECT_TRUE(fileid1.ElfFileIdentifier(identifier1));
66 FileID fileid2(templ);
67 EXPECT_TRUE(fileid2.ElfFileIdentifier(identifier2));
68 char identifier_string1[37];
69 char identifier_string2[37];
70 FileID::ConvertIdentifierToString(identifier1, identifier_string1,
71 37);
72 FileID::ConvertIdentifierToString(identifier2, identifier_string2,
73 37);
74 EXPECT_STREQ(identifier_string1, identifier_string2);
75 unlink(templ);
76 }
OLDNEW
« no previous file with comments | « obsolete/breakpad/common/linux/file_id.cc ('k') | obsolete/breakpad/common/linux/google_crashdump_uploader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698