зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1546587 - Include the TestZip zip files as binary data. r=froydnj
We're going to convert the test to a gtest, and it's simpler not to have to deal with finding the path to the testcase zip files. They're small enough anyways, and can be inserted as raw binary data via some assembly magic. This being android-only code, we don't need extreme portability here. This is the same trick we use in config/external/icu/data/icudata_gas.S. Differential Revision: https://phabricator.services.mozilla.com/D28758 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
cf749be8f7
Коммит
36b33e0796
|
@ -10,12 +10,37 @@
|
|||
extern "C" void report_mapping() {}
|
||||
extern "C" void delete_mapping() {}
|
||||
|
||||
/**
|
||||
* ZIP_DATA(FOO, "foo") defines the variables FOO and FOO_SIZE.
|
||||
* The former contains the content of the "foo" file in the same directory
|
||||
* as this file, and FOO_SIZE its size.
|
||||
*/
|
||||
/* clang-format off */
|
||||
#define ZIP_DATA(name, file) \
|
||||
__asm__(".global " #name "\n" \
|
||||
".data\n" \
|
||||
".balign 16\n" \
|
||||
#name ":\n" \
|
||||
" .incbin \"" SRCDIR "/" file "\"\n" \
|
||||
".L" #name "_END:\n" \
|
||||
" .size " #name ", .L" #name "_END-" #name \
|
||||
"\n" \
|
||||
".global " #name "_SIZE\n" \
|
||||
".data\n" \
|
||||
".balign 4\n" \
|
||||
#name "_SIZE:\n" \
|
||||
" .int .L" #name "_END-" #name "\n"); \
|
||||
extern const unsigned char name[]; \
|
||||
extern const unsigned int name##_SIZE
|
||||
/* clang-format on */
|
||||
|
||||
/**
|
||||
* test.zip is a basic test zip file with a central directory. It contains
|
||||
* four entries, in the following order:
|
||||
* "foo", "bar", "baz", "qux".
|
||||
* The entries are going to be read out of order.
|
||||
*/
|
||||
ZIP_DATA(TEST_ZIP, "test.zip");
|
||||
const char *test_entries[] = {"baz", "foo", "bar", "qux"};
|
||||
|
||||
/**
|
||||
|
@ -32,18 +57,12 @@ const char *test_entries[] = {"baz", "foo", "bar", "qux"};
|
|||
* zipalign if it had a data descriptor originally.
|
||||
* - Fourth entry is a file "d", STOREd.
|
||||
*/
|
||||
ZIP_DATA(NO_CENTRAL_DIR_ZIP, "no_central_dir.zip");
|
||||
const char *no_central_dir_entries[] = {"a", "b", "c", "d"};
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc != 2) {
|
||||
fprintf(
|
||||
stderr,
|
||||
"TEST-FAIL | TestZip | Expecting the directory containing test Zips\n");
|
||||
return 1;
|
||||
}
|
||||
chdir(argv[1]);
|
||||
Zip::Stream s;
|
||||
RefPtr<Zip> z = ZipCollection::GetZip("test.zip");
|
||||
RefPtr<Zip> z = Zip::Create((void *)TEST_ZIP, TEST_ZIP_SIZE);
|
||||
for (auto& entry : test_entries) {
|
||||
if (!z->GetStream(entry, &s)) {
|
||||
fprintf(stderr,
|
||||
|
@ -55,7 +74,7 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
fprintf(stderr, "TEST-PASS | TestZip | test.zip could be accessed fully\n");
|
||||
|
||||
z = ZipCollection::GetZip("no_central_dir.zip");
|
||||
z = Zip::Create((void *)NO_CENTRAL_DIR_ZIP, NO_CENTRAL_DIR_ZIP_SIZE);
|
||||
for (auto& entry : no_central_dir_entries) {
|
||||
if (!z->GetStream(entry, &s)) {
|
||||
fprintf(stderr,
|
||||
|
|
|
@ -24,3 +24,5 @@ PYTHON_UNITTEST_MANIFESTS += ['python.ini']
|
|||
|
||||
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
|
||||
CXXFLAGS += ['-Wno-error=shadow']
|
||||
|
||||
DEFINES['SRCDIR'] = '"%s"' % SRCDIR
|
||||
|
|
Загрузка…
Ссылка в новой задаче