Commit a1b71cc6 authored by David 'Digit' Turner's avatar David 'Digit' Turner Committed by Commit Bot

android: crazy_linker: Update zip test data tables.

This CL moves the data tables used to test the zip parsing code
into its own source file.

Also modify generate_zip_test_tables.sh to also generate data for
a zip archive that contains two mock uncompressed shared libraries.
These will be used in a future CL that changes the way the crazy
linker loads files from zip archives.

BUG=802068
R=agrieve@chromium.org, lizeb@chromium.org, pasko@chromium.org

Change-Id: Ifb440eb3c050227bb3e9354f4ead859824362c76
Reviewed-on: https://chromium-review.googlesource.com/1042245
Commit-Queue: David Turner <digit@chromium.org>
Reviewed-by: default avatarEgor Pasko <pasko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555847}
parent cbd1a7a6
...@@ -151,6 +151,8 @@ if (is_android) { ...@@ -151,6 +151,8 @@ if (is_android) {
"src/src/crazy_linker_system_unittest.cpp", "src/src/crazy_linker_system_unittest.cpp",
"src/src/crazy_linker_thread_unittest.cpp", "src/src/crazy_linker_thread_unittest.cpp",
"src/src/crazy_linker_util_unittest.cpp", "src/src/crazy_linker_util_unittest.cpp",
"src/src/crazy_linker_zip_test_data.cpp",
"src/src/crazy_linker_zip_test_data.h",
"src/src/crazy_linker_zip_unittest.cpp", "src/src/crazy_linker_zip_unittest.cpp",
] ]
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// AUTO-GENERATED BY generate_zip_test_tables.sh - DO NOT EDIT!!
#include "crazy_linker_zip_test_data.h"
namespace crazy {
namespace testing {
// An empty zip archive
const unsigned char empty_archive_zip[] = {
0x50, 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned int empty_archive_zip_len = 22;
// A zip archive with a single file named 'hello_world.txt' that
// contains the bytes for 'Hello World Hello World\n' without
// compression.
const unsigned char hello_zip[] = {
0x50, 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd4, 0x86,
0xa3, 0x4c, 0xfd, 0x95, 0x3b, 0x3f, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00,
0x00, 0x00, 0x0f, 0x00, 0x1c, 0x00, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x5f,
0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x74, 0x78, 0x74, 0x55, 0x54, 0x09,
0x00, 0x03, 0xb0, 0x22, 0xeb, 0x5a, 0xb0, 0x22, 0xeb, 0x5a, 0x75, 0x78,
0x0b, 0x00, 0x01, 0x04, 0xab, 0x6f, 0x00, 0x00, 0x04, 0x53, 0x5f, 0x01,
0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64,
0x20, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64,
0x0a, 0x50, 0x4b, 0x01, 0x02, 0x1e, 0x03, 0x0a, 0x00, 0x00, 0x00, 0x00,
0x00, 0xd4, 0x86, 0xa3, 0x4c, 0xfd, 0x95, 0x3b, 0x3f, 0x18, 0x00, 0x00,
0x00, 0x18, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x81, 0x00, 0x00, 0x00, 0x00, 0x68,
0x65, 0x6c, 0x6c, 0x6f, 0x5f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x74,
0x78, 0x74, 0x55, 0x54, 0x05, 0x00, 0x03, 0xb0, 0x22, 0xeb, 0x5a, 0x75,
0x78, 0x0b, 0x00, 0x01, 0x04, 0xab, 0x6f, 0x00, 0x00, 0x04, 0x53, 0x5f,
0x01, 0x00, 0x50, 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
0x01, 0x00, 0x55, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned int hello_zip_len = 204;
// The same zip archive, but with the file stored compressed.
const unsigned char hello_compressed_zip[] = {
0x50, 0x4b, 0x03, 0x04, 0x14, 0x00, 0x02, 0x00, 0x08, 0x00, 0xd4, 0x86,
0xa3, 0x4c, 0xfd, 0x95, 0x3b, 0x3f, 0x11, 0x00, 0x00, 0x00, 0x18, 0x00,
0x00, 0x00, 0x0f, 0x00, 0x1c, 0x00, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x5f,
0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x74, 0x78, 0x74, 0x55, 0x54, 0x09,
0x00, 0x03, 0xb0, 0x22, 0xeb, 0x5a, 0xb0, 0x22, 0xeb, 0x5a, 0x75, 0x78,
0x0b, 0x00, 0x01, 0x04, 0xab, 0x6f, 0x00, 0x00, 0x04, 0x53, 0x5f, 0x01,
0x00, 0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0x57, 0x08, 0xcf, 0x2f, 0xca, 0x49,
0x51, 0xf0, 0x40, 0xb0, 0xb9, 0x00, 0x50, 0x4b, 0x01, 0x02, 0x1e, 0x03,
0x14, 0x00, 0x02, 0x00, 0x08, 0x00, 0xd4, 0x86, 0xa3, 0x4c, 0xfd, 0x95,
0x3b, 0x3f, 0x11, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0f, 0x00,
0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa4, 0x81,
0x00, 0x00, 0x00, 0x00, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x5f, 0x77, 0x6f,
0x72, 0x6c, 0x64, 0x2e, 0x74, 0x78, 0x74, 0x55, 0x54, 0x05, 0x00, 0x03,
0xb0, 0x22, 0xeb, 0x5a, 0x75, 0x78, 0x0b, 0x00, 0x01, 0x04, 0xab, 0x6f,
0x00, 0x00, 0x04, 0x53, 0x5f, 0x01, 0x00, 0x50, 0x4b, 0x05, 0x06, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x55, 0x00, 0x00, 0x00, 0x5a,
0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned int hello_compressed_zip_len = 197;
// A zip archive with two uncompressed files under lib/test-abi/
// named 'libfoo.so' and 'crazy.libbar.so', with the following data:
// - first lib: 'This is the first test library!'
// - second lib: 'This is the second test library!'
const unsigned char lib_archive_zip[] = {
0x50, 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd4, 0x86,
0xa3, 0x4c, 0x84, 0x92, 0x26, 0x8e, 0x1f, 0x00, 0x00, 0x00, 0x1f, 0x00,
0x00, 0x00, 0x16, 0x00, 0x1c, 0x00, 0x6c, 0x69, 0x62, 0x2f, 0x74, 0x65,
0x73, 0x74, 0x2d, 0x61, 0x62, 0x69, 0x2f, 0x6c, 0x69, 0x62, 0x66, 0x6f,
0x6f, 0x2e, 0x73, 0x6f, 0x55, 0x54, 0x09, 0x00, 0x03, 0xb0, 0x22, 0xeb,
0x5a, 0xb0, 0x22, 0xeb, 0x5a, 0x75, 0x78, 0x0b, 0x00, 0x01, 0x04, 0xab,
0x6f, 0x00, 0x00, 0x04, 0x53, 0x5f, 0x01, 0x00, 0x54, 0x68, 0x69, 0x73,
0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x66, 0x69, 0x72, 0x73,
0x74, 0x20, 0x74, 0x65, 0x73, 0x74, 0x20, 0x6c, 0x69, 0x62, 0x72, 0x61,
0x72, 0x79, 0x21, 0x50, 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00,
0x00, 0xd4, 0x86, 0xa3, 0x4c, 0xa0, 0xb1, 0x85, 0x09, 0x20, 0x00, 0x00,
0x00, 0x20, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x1c, 0x00, 0x6c, 0x69, 0x62,
0x2f, 0x74, 0x65, 0x73, 0x74, 0x2d, 0x61, 0x62, 0x69, 0x2f, 0x63, 0x72,
0x61, 0x7a, 0x79, 0x2e, 0x6c, 0x69, 0x62, 0x62, 0x61, 0x72, 0x2e, 0x73,
0x6f, 0x55, 0x54, 0x09, 0x00, 0x03, 0xb0, 0x22, 0xeb, 0x5a, 0xb0, 0x22,
0xeb, 0x5a, 0x75, 0x78, 0x0b, 0x00, 0x01, 0x04, 0xab, 0x6f, 0x00, 0x00,
0x04, 0x53, 0x5f, 0x01, 0x00, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73,
0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20,
0x74, 0x65, 0x73, 0x74, 0x20, 0x6c, 0x69, 0x62, 0x72, 0x61, 0x72, 0x79,
0x21, 0x50, 0x4b, 0x01, 0x02, 0x1e, 0x03, 0x0a, 0x00, 0x00, 0x00, 0x00,
0x00, 0xd4, 0x86, 0xa3, 0x4c, 0x84, 0x92, 0x26, 0x8e, 0x1f, 0x00, 0x00,
0x00, 0x1f, 0x00, 0x00, 0x00, 0x16, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x81, 0x00, 0x00, 0x00, 0x00, 0x6c,
0x69, 0x62, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2d, 0x61, 0x62, 0x69, 0x2f,
0x6c, 0x69, 0x62, 0x66, 0x6f, 0x6f, 0x2e, 0x73, 0x6f, 0x55, 0x54, 0x05,
0x00, 0x03, 0xb0, 0x22, 0xeb, 0x5a, 0x75, 0x78, 0x0b, 0x00, 0x01, 0x04,
0xab, 0x6f, 0x00, 0x00, 0x04, 0x53, 0x5f, 0x01, 0x00, 0x50, 0x4b, 0x01,
0x02, 0x1e, 0x03, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd4, 0x86, 0xa3,
0x4c, 0xa0, 0xb1, 0x85, 0x09, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
0x00, 0x1c, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xa4, 0x81, 0x6f, 0x00, 0x00, 0x00, 0x6c, 0x69, 0x62, 0x2f, 0x74,
0x65, 0x73, 0x74, 0x2d, 0x61, 0x62, 0x69, 0x2f, 0x63, 0x72, 0x61, 0x7a,
0x79, 0x2e, 0x6c, 0x69, 0x62, 0x62, 0x61, 0x72, 0x2e, 0x73, 0x6f, 0x55,
0x54, 0x05, 0x00, 0x03, 0xb0, 0x22, 0xeb, 0x5a, 0x75, 0x78, 0x0b, 0x00,
0x01, 0x04, 0xab, 0x6f, 0x00, 0x00, 0x04, 0x53, 0x5f, 0x01, 0x00, 0x50,
0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0xbe,
0x00, 0x00, 0x00, 0xe5, 0x00, 0x00, 0x00, 0x00, 0x00};
const unsigned int lib_archive_zip_len = 441;
} // namespace testing
} // namespace crazy
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CRAZY_LINKER_ZIP_TEST_DATA_H
#define CRAZY_LINKER_ZIP_TEST_DATA_H
namespace crazy {
namespace testing {
extern const unsigned char empty_archive_zip[];
extern const unsigned int empty_archive_zip_len;
extern const unsigned char hello_zip[];
extern const unsigned int hello_zip_len;
extern const unsigned char hello_compressed_zip[];
extern const unsigned int hello_compressed_zip_len;
extern const unsigned char lib_archive_zip[];
extern const unsigned int lib_archive_zip_len;
} // namespace testing
} // namespace crazy
#endif // CRAZY_LINKER_ZIP_TEST_DATA_H
...@@ -8,67 +8,15 @@ ...@@ -8,67 +8,15 @@
#include "crazy_linker_util.h" // FOR CRAZY_OFFSET_FAILED? #include "crazy_linker_util.h" // FOR CRAZY_OFFSET_FAILED?
#include "crazy_linker_zip_archive.h" #include "crazy_linker_zip_archive.h"
#include "crazy_linker_zip_test_data.h"
#include <gtest/gtest.h> #include <gtest/gtest.h>
namespace crazy { namespace crazy {
namespace { using namespace crazy::testing;
// START OF AUTO-GENERATED SECTION - DO NOT EDIT namespace {
// This section was generated by generate_zip_test_tables.sh
// An empty zip archive
unsigned char empty_archive_zip[] = {
0x50, 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
unsigned int empty_archive_zip_len = 22;
// A zip archive with a single file named 'hello_world.txt' that
// contains the bytes for 'Hello World Hello World\n' without
// compression.
unsigned char hello_zip[] = {
0x50, 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x75,
0x49, 0x4c, 0xfd, 0x95, 0x3b, 0x3f, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00,
0x00, 0x00, 0x0f, 0x00, 0x1c, 0x00, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x5f,
0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x74, 0x78, 0x74, 0x55, 0x54, 0x09,
0x00, 0x03, 0xd6, 0xa4, 0x7d, 0x5a, 0xd6, 0xa4, 0x7d, 0x5a, 0x75, 0x78,
0x0b, 0x00, 0x01, 0x04, 0xab, 0x6f, 0x00, 0x00, 0x04, 0x88, 0x13, 0x00,
0x00, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64,
0x20, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64,
0x0a, 0x50, 0x4b, 0x01, 0x02, 0x1e, 0x03, 0x0a, 0x00, 0x00, 0x00, 0x00,
0x00, 0x13, 0x75, 0x49, 0x4c, 0xfd, 0x95, 0x3b, 0x3f, 0x18, 0x00, 0x00,
0x00, 0x18, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x81, 0x00, 0x00, 0x00, 0x00, 0x68,
0x65, 0x6c, 0x6c, 0x6f, 0x5f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x74,
0x78, 0x74, 0x55, 0x54, 0x05, 0x00, 0x03, 0xd6, 0xa4, 0x7d, 0x5a, 0x75,
0x78, 0x0b, 0x00, 0x01, 0x04, 0xab, 0x6f, 0x00, 0x00, 0x04, 0x88, 0x13,
0x00, 0x00, 0x50, 0x4b, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
0x01, 0x00, 0x55, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00};
unsigned int hello_zip_len = 204;
// The same zip archive, but with the file stored compressed.
unsigned char hello_compressed_zip[] = {
0x50, 0x4b, 0x03, 0x04, 0x14, 0x00, 0x02, 0x00, 0x08, 0x00, 0x13, 0x75,
0x49, 0x4c, 0xfd, 0x95, 0x3b, 0x3f, 0x11, 0x00, 0x00, 0x00, 0x18, 0x00,
0x00, 0x00, 0x0f, 0x00, 0x1c, 0x00, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x5f,
0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x74, 0x78, 0x74, 0x55, 0x54, 0x09,
0x00, 0x03, 0xd6, 0xa4, 0x7d, 0x5a, 0xd6, 0xa4, 0x7d, 0x5a, 0x75, 0x78,
0x0b, 0x00, 0x01, 0x04, 0xab, 0x6f, 0x00, 0x00, 0x04, 0x88, 0x13, 0x00,
0x00, 0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0x57, 0x08, 0xcf, 0x2f, 0xca, 0x49,
0x51, 0xf0, 0x40, 0xb0, 0xb9, 0x00, 0x50, 0x4b, 0x01, 0x02, 0x1e, 0x03,
0x14, 0x00, 0x02, 0x00, 0x08, 0x00, 0x13, 0x75, 0x49, 0x4c, 0xfd, 0x95,
0x3b, 0x3f, 0x11, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0f, 0x00,
0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0xa0, 0x81,
0x00, 0x00, 0x00, 0x00, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x5f, 0x77, 0x6f,
0x72, 0x6c, 0x64, 0x2e, 0x74, 0x78, 0x74, 0x55, 0x54, 0x05, 0x00, 0x03,
0xd6, 0xa4, 0x7d, 0x5a, 0x75, 0x78, 0x0b, 0x00, 0x01, 0x04, 0xab, 0x6f,
0x00, 0x00, 0x04, 0x88, 0x13, 0x00, 0x00, 0x50, 0x4b, 0x05, 0x06, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x55, 0x00, 0x00, 0x00, 0x5a,
0x00, 0x00, 0x00, 0x00, 0x00};
unsigned int hello_compressed_zip_len = 197;
// END OF AUTO-GENERATED SECTION
// Convenience function to add a file to the mock filesystem from the // Convenience function to add a file to the mock filesystem from the
// data tables above. // data tables above.
...@@ -129,7 +77,8 @@ ZipLocalFileHeader* LocateLocalFileHeader(unsigned char* data, ...@@ -129,7 +77,8 @@ ZipLocalFileHeader* LocateLocalFileHeader(unsigned char* data,
// Find the offset of the file 'hello_world.txt' in the zip archive // Find the offset of the file 'hello_world.txt' in the zip archive
// stored at |data| with |data_size| bytes. Return CRAZY_OFFSET_FAILED if // stored at |data| with |data_size| bytes. Return CRAZY_OFFSET_FAILED if
// not found. // not found.
int32_t FindHelloWorldZipFileOffset(unsigned char* data, size_t data_size) { int32_t FindHelloWorldZipFileOffset(const unsigned char* data,
size_t data_size) {
SystemMock sys; SystemMock sys;
AddZipArchiveBytes(&sys, "hello.zip", data, data_size); AddZipArchiveBytes(&sys, "hello.zip", data, data_size);
return FindStartOffsetOfFileInZipFile("hello.zip", "hello_world.txt"); return FindStartOffsetOfFileInZipFile("hello.zip", "hello_world.txt");
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
# Simple script used to regenerate zip files used for unit-testing the # Simple script used to regenerate zip files used for unit-testing the
# crazy linker zip parser. This outputs a fragment of C code through 'xdd' # crazy linker zip parser. This outputs a fragment of C code through 'xdd'
# on Linux that can be copied into crazy_linker_zip_unittest.cpp directly. # on Linux that can be copied into crazy_linker_zip_test_data.cpp directly.
set -e set -e
...@@ -20,19 +20,38 @@ die () { ...@@ -20,19 +20,38 @@ die () {
TMP_DIR=/tmp/zip-files-tmp-$$ TMP_DIR=/tmp/zip-files-tmp-$$
OUTPUT_DIR=/tmp/zip-files OUTPUT_DIR=/tmp/zip-files
generate_c_source () {
# Turn generated table const, it's cleaner.
# Also indent with 4 spaces (Chromium style).
xxd -i $1 | \
sed -e 's/^unsigned/const unsigned/g' | \
sed -e 's/^ 0x/ 0x/g'
}
# Preparing temporary directory. # Preparing temporary directory.
mkdir -p $TMP_DIR mkdir -p $TMP_DIR
rm -rf $TMP_DIR/* rm -rf $TMP_DIR/*
cd $TMP_DIR cd $TMP_DIR
printf "// START OF AUTO-GENERATED SECTION - DO NOT EDIT\n" cat <<EOF
printf "// This section was generated by $PROGNAME\n\n" // Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// AUTO-GENERATED BY $PROGNAME - DO NOT EDIT!!
#include "crazy_linker_zip_test_data.h"
namespace crazy {
namespace testing {
EOF
printf "// An empty zip archive\n" printf "// An empty zip archive\n"
touch empty_file touch empty_file
zip -q empty_archive empty_file zip -q empty_archive empty_file
zip -q -d empty_archive empty_file 2>/dev/null zip -q -d empty_archive empty_file 2>/dev/null
xxd -i empty_archive.zip generate_c_source empty_archive.zip
printf "\n" printf "\n"
printf "// A zip archive with a single file named 'hello_world.txt' that\n" printf "// A zip archive with a single file named 'hello_world.txt' that\n"
...@@ -40,14 +59,35 @@ printf "// contains the bytes for 'Hello World Hello World\\\n' without\n" ...@@ -40,14 +59,35 @@ printf "// contains the bytes for 'Hello World Hello World\\\n' without\n"
printf "// compression.\n" printf "// compression.\n"
echo "Hello World Hello World" > hello_world.txt echo "Hello World Hello World" > hello_world.txt
zip -q -0 hello.zip hello_world.txt zip -q -0 hello.zip hello_world.txt
xxd -i hello.zip generate_c_source hello.zip
printf "\n" printf "\n"
printf "// The same zip archive, but with the file stored compressed.\n" printf "// The same zip archive, but with the file stored compressed.\n"
zip -q -9 hello_compressed.zip hello_world.txt zip -q -9 hello_compressed.zip hello_world.txt
xxd -i hello_compressed.zip generate_c_source hello_compressed.zip
printf "\n" printf "\n"
printf "// END OF AUTO-GENERATED SECTION\n\n" LIB_SUBDIR=lib/test-abi
LIB1_NAME=libfoo.so
LIB2_NAME=crazy.libbar.so
LIB1_TEXT="This is the first test library!"
LIB2_TEXT="This is the second test library!"
cat <<EOF
// A zip archive with two uncompressed files under $LIB_SUBDIR/
// named '$LIB1_NAME' and '$LIB2_NAME', with the following data:
// - first lib: '$LIB1_TEXT'
// - second lib: '$LIB2_TEXT'
EOF
mkdir -p $LIB_SUBDIR
printf "This is the first test library!" > $LIB_SUBDIR/$LIB1_NAME
printf "This is the second test library!" > $LIB_SUBDIR/$LIB2_NAME
zip -q -0 lib_archive.zip $LIB_SUBDIR/$LIB1_NAME $LIB_SUBDIR/$LIB2_NAME
generate_c_source lib_archive.zip
cat <<EOF
} // namespace testing
} // namespace crazy
EOF
rm -rf $TMP_DIR rm -rf $TMP_DIR
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment