• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "puffin/src/unittest_common.h"
6 
7 using std::string;
8 using std::vector;
9 
10 namespace puffin {
11 
MakeTempFile(string * filename,int * fd)12 bool MakeTempFile(string* filename, int* fd) {
13 #ifdef __ANDROID__
14   char tmp_template[] = "/data/local/tmp/puffin-XXXXXX";
15 #else
16   char tmp_template[] = "/tmp/puffin-XXXXXX";
17 #endif  // __ANDROID__
18   int mkstemp_fd = mkstemp(tmp_template);
19   TEST_AND_RETURN_FALSE(mkstemp_fd >= 0);
20   if (filename) {
21     *filename = tmp_template;
22   }
23   if (fd) {
24     *fd = mkstemp_fd;
25   } else {
26     close(mkstemp_fd);
27   }
28   return true;
29 }
30 
31 // clang-format off
32 const Buffer kDeflatesSample1 = {
33     /* raw   0 */ 0x11, 0x22,
34     /* def   2 */ 0x63, 0x64, 0x62, 0x66, 0x61, 0x05, 0x00,
35     /* raw   9 */ 0x33,
36     /* def  10 */ 0x03, 0x00,
37     /* raw  12 */
38     /* def  12 */ 0x63, 0x04, 0x00,
39     /* raw  15 */ 0x44, 0x55
40 };
41 const Buffer kPuffsSample1 = {
42     /* raw   0 */ 0x11, 0x22,
43     /* puff  2 */ 0x00, 0x00, 0xA0, 0x04, 0x01, 0x02, 0x03, 0x04, 0x05, 0xFF,
44                   0x81,
45     /* raw  13 */ 0x00, 0x33,
46     /* puff 15 */ 0x00, 0x00, 0xA0, 0xFF, 0x81,
47     /* raw  20 */ 0x00,
48     /* puff 21 */ 0x00, 0x00, 0xA0, 0x00, 0x01, 0xFF, 0x81,
49     /* raw  28 */ 0x00, 0x44, 0x55
50 };
51 const vector<ByteExtent> kDeflateExtentsSample1 = {
52   {2, 7}, {10, 2}, {12, 3}};
53 const vector<BitExtent> kSubblockDeflateExtentsSample1 = {
54   {16, 50}, {80, 10}, {96, 18}};
55 const vector<ByteExtent> kPuffExtentsSample1 = {{2, 11}, {15, 5}, {21, 7}};
56 
57 const Buffer kDeflatesSample2 = {
58     /* def  0  */ 0x63, 0x64, 0x62, 0x66, 0x61, 0x05, 0x00,
59     /* raw  7  */ 0x33, 0x66,
60     /* def  9  */ 0x01, 0x05, 0x00, 0xFA, 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05,
61     /* def  19 */ 0x63, 0x04, 0x00
62 };
63 const Buffer kPuffsSample2 = {
64     /* puff  0 */ 0x00, 0x00, 0xA0, 0x04, 0x01, 0x02, 0x03, 0x04, 0x05, 0xFF,
65                   0x81,
66     /* raw  11 */ 0x00, 0x33, 0x66,
67     /* puff 14 */ 0x00, 0x00, 0x80, 0x04, 0x01, 0x02, 0x03, 0x04, 0x05, 0xFF,
68                   0x81,
69     /* puff 25 */ 0x00, 0x00, 0xA0, 0x00, 0x01, 0xFF, 0x81,
70     /* raw  32 */ 0x00,
71 };
72 const vector<ByteExtent> kDeflateExtentsSample2 = {
73   {0, 7}, {9, 10}, {19, 3}};
74 const vector<BitExtent> kSubblockDeflateExtentsSample2 = {
75   {0, 50}, {72, 80}, {152, 18}};
76 const vector<ByteExtent> kPuffExtentsSample2 = {
77   {0, 11}, {14, 11}, {25, 7}};
78 // clang-format on
79 
80 // This data is taken from the failed instances described in crbug.com/915559.
81 const Buffer kProblematicCache = {
82     0x51, 0x74, 0x97, 0x71, 0x51, 0x6e, 0x6d, 0x1b, 0x87, 0x4f, 0x5b,
83     0xb1, 0xbb, 0xb6, 0xdd, 0xdd, 0xdd, 0x89, 0x89, 0xa2, 0x88, 0x9d,
84     0x18, 0x4c, 0x1a, 0x8c, 0x8a, 0x1d, 0xa8, 0xd8, 0x89, 0xdd, 0xdd,
85     0x81, 0x89, 0x62, 0x77, 0xb7, 0x32, 0x81, 0x31, 0x98, 0x88, 0x5d,
86     0x83, 0xbd, 0xff, 0xf3, 0xe1, 0xf8, 0x9d, 0xd7, 0xba, 0xd6, 0x9a,
87     0x7b, 0x86, 0x99, 0x3b, 0xf7, 0xbb, 0xdf, 0xfd, 0x90, 0xf0, 0x45,
88     0x0b, 0xb4, 0x44, 0x2b, 0xb4, 0x46, 0x1b, 0xb4, 0xc5, 0xff};
89 const vector<BitExtent> kProblematicCacheDeflateExtents = {{2, 606}};
90 const vector<BitExtent> kProblematicCachePuffExtents = {{1, 185}};
91 
92 }  // namespace puffin
93