зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1546587 - Convert TestZip to a gtest. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D28759 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
36b33e0796
Коммит
e12a4b2881
|
@ -7,8 +7,9 @@
|
|||
#include "Zip.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
|
||||
extern "C" void report_mapping() {}
|
||||
extern "C" void delete_mapping() {}
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
Logging Logging::Singleton;
|
||||
|
||||
/**
|
||||
* ZIP_DATA(FOO, "foo") defines the variables FOO and FOO_SIZE.
|
||||
|
@ -60,33 +61,23 @@ const char *test_entries[] = {"baz", "foo", "bar", "qux"};
|
|||
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[]) {
|
||||
TEST(Zip, TestZip)
|
||||
{
|
||||
Zip::Stream s;
|
||||
RefPtr<Zip> z = Zip::Create((void *)TEST_ZIP, TEST_ZIP_SIZE);
|
||||
for (auto& entry : test_entries) {
|
||||
if (!z->GetStream(entry, &s)) {
|
||||
fprintf(stderr,
|
||||
"TEST-UNEXPECTED-FAIL | TestZip | test.zip: Couldn't get entry "
|
||||
"\"%s\"\n",
|
||||
entry);
|
||||
return 1;
|
||||
}
|
||||
ASSERT_TRUE(z->GetStream(entry, &s))
|
||||
<< "Could not get entry \"" << entry << "\"";
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Zip, NoCentralDir)
|
||||
{
|
||||
Zip::Stream s;
|
||||
RefPtr<Zip> z =
|
||||
Zip::Create((void *)NO_CENTRAL_DIR_ZIP, NO_CENTRAL_DIR_ZIP_SIZE);
|
||||
for (auto& entry : no_central_dir_entries) {
|
||||
ASSERT_TRUE(z->GetStream(entry, &s))
|
||||
<< "Could not get entry \"" << entry << "\"";
|
||||
}
|
||||
fprintf(stderr, "TEST-PASS | TestZip | test.zip could be accessed fully\n");
|
||||
|
||||
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,
|
||||
"TEST-UNEXPECTED-FAIL | TestZip | no_central_dir.zip: Couldn't "
|
||||
"get entry \"%s\"\n",
|
||||
entry);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
fprintf(
|
||||
stderr,
|
||||
"TEST-PASS | TestZip | no_central_dir.zip could be accessed in order\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -4,23 +4,14 @@
|
|||
# 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
|
||||
FINAL_LIBRARY = 'xul-gtest'
|
||||
|
||||
SimplePrograms([
|
||||
'TestZip',
|
||||
])
|
||||
LOCAL_INCLUDES += ['..']
|
||||
USE_LIBS += [
|
||||
'linker',
|
||||
'mfbt',
|
||||
UNIFIED_SOURCES += [
|
||||
'../Zip.cpp',
|
||||
'TestZip.cpp',
|
||||
]
|
||||
if CONFIG['ZLIB_IN_MOZGLUE']:
|
||||
USE_LIBS += [ 'modules_zlib_src' ]
|
||||
else:
|
||||
OS_LIBS += CONFIG['MOZ_ZLIB_LIBS']
|
||||
DisableStlWrapping()
|
||||
|
||||
PYTHON_UNITTEST_MANIFESTS += ['python.ini']
|
||||
LOCAL_INCLUDES += ['..']
|
||||
|
||||
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
|
||||
CXXFLAGS += ['-Wno-error=shadow']
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
[DEFAULT]
|
||||
skip-if = python == 3
|
||||
|
||||
[run_test_zip.py]
|
|
@ -1,23 +0,0 @@
|
|||
#!/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()
|
Загрузка…
Ссылка в новой задаче