diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /mozglue/linker/tests | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'mozglue/linker/tests')
-rw-r--r-- | mozglue/linker/tests/TestZip.cpp | 69 | ||||
-rw-r--r-- | mozglue/linker/tests/moz.build | 23 | ||||
-rw-r--r-- | mozglue/linker/tests/no_central_dir.zip | bin | 0 -> 281 bytes | |||
-rw-r--r-- | mozglue/linker/tests/run_test_zip.py | 21 | ||||
-rw-r--r-- | mozglue/linker/tests/test.zip | bin | 0 -> 574 bytes |
5 files changed, 113 insertions, 0 deletions
diff --git a/mozglue/linker/tests/TestZip.cpp b/mozglue/linker/tests/TestZip.cpp new file mode 100644 index 000000000..25873f5e5 --- /dev/null +++ b/mozglue/linker/tests/TestZip.cpp @@ -0,0 +1,69 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include <cstdio> +#include <unistd.h> +#include "Zip.h" +#include "mozilla/RefPtr.h" + +extern "C" void report_mapping() { } +extern "C" void delete_mapping() { } + +/** + * 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. + */ +const char *test_entries[] = { + "baz", "foo", "bar", "qux" +}; + +/** + * no_central_dir.zip is a hand crafted test zip with no central directory + * entries. The Zip reader is expected to be able to traverse these entries + * if requested in order, without reading a central directory + * - First entry is a file "a", STOREd. + * - Second entry is a file "b", STOREd, using a data descriptor. CRC is + * unknown, but compressed and uncompressed sizes are known in the local + * file header. + * - Third entry is a file "c", DEFLATEd, using a data descriptor. CRC, + * compressed and uncompressed sizes are known in the local file header. + * This is the kind of entry that can be found in a zip that went through + * zipalign if it had a data descriptor originally. + * - Fourth entry is a file "d", STOREd. + */ +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"); + for (size_t i = 0; i < sizeof(test_entries) / sizeof(*test_entries); i++) { + if (!z->GetStream(test_entries[i], &s)) { + fprintf(stderr, "TEST-UNEXPECTED-FAIL | TestZip | test.zip: Couldn't get entry \"%s\"\n", test_entries[i]); + return 1; + } + } + fprintf(stderr, "TEST-PASS | TestZip | test.zip could be accessed fully\n"); + + z = ZipCollection::GetZip("no_central_dir.zip"); + for (size_t i = 0; i < sizeof(no_central_dir_entries) + / sizeof(*no_central_dir_entries); i++) { + if (!z->GetStream(no_central_dir_entries[i], &s)) { + fprintf(stderr, "TEST-UNEXPECTED-FAIL | TestZip | no_central_dir.zip: Couldn't get entry \"%s\"\n", no_central_dir_entries[i]); + return 1; + } + } + fprintf(stderr, "TEST-PASS | TestZip | no_central_dir.zip could be accessed in order\n"); + + return 0; +} diff --git a/mozglue/linker/tests/moz.build b/mozglue/linker/tests/moz.build new file mode 100644 index 000000000..3d4c1c616 --- /dev/null +++ b/mozglue/linker/tests/moz.build @@ -0,0 +1,23 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +DIST_INSTALL = False + +SimplePrograms([ + 'TestZip', +]) +LOCAL_INCLUDES += ['..'] +USE_LIBS += [ + 'linker', + 'mfbt', +] +OS_LIBS += CONFIG['MOZ_ZLIB_LIBS'] +DISABLE_STL_WRAPPING = True + +PYTHON_UNIT_TESTS += ['run_test_zip.py'] + +if CONFIG['GNU_CXX']: + CXXFLAGS += ['-Wno-error=shadow'] diff --git a/mozglue/linker/tests/no_central_dir.zip b/mozglue/linker/tests/no_central_dir.zip Binary files differnew file mode 100644 index 000000000..df882220d --- /dev/null +++ b/mozglue/linker/tests/no_central_dir.zip diff --git a/mozglue/linker/tests/run_test_zip.py b/mozglue/linker/tests/run_test_zip.py new file mode 100644 index 000000000..e606e16d4 --- /dev/null +++ b/mozglue/linker/tests/run_test_zip.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +# +# Any copyright is dedicated to the Public Domain. +# http://creativecommons.org/publicdomain/zero/1.0/ + +import buildconfig +import mozpack.path as mozpath +import mozunit +import subprocess +import unittest + +class TestZip(unittest.TestCase): + def test_zip(self): + srcdir = mozpath.dirname(__file__) + relsrcdir = mozpath.relpath(srcdir, buildconfig.topsrcdir) + test_bin = mozpath.join(buildconfig.topobjdir, relsrcdir, + 'TestZip' + buildconfig.substs['BIN_SUFFIX']) + self.assertEqual(0, subprocess.call([test_bin, srcdir])) + +if __name__ == '__main__': + mozunit.main() diff --git a/mozglue/linker/tests/test.zip b/mozglue/linker/tests/test.zip Binary files differnew file mode 100644 index 000000000..657835b0c --- /dev/null +++ b/mozglue/linker/tests/test.zip |