summaryrefslogtreecommitdiff
path: root/nss/gtests/common
diff options
context:
space:
mode:
Diffstat (limited to 'nss/gtests/common')
-rw-r--r--nss/gtests/common/common.gyp35
-rw-r--r--nss/gtests/common/gtest.gypi16
-rw-r--r--nss/gtests/common/gtests.cc8
-rw-r--r--nss/gtests/common/manifest.mn3
-rw-r--r--nss/gtests/common/scoped_ptrs.h61
5 files changed, 21 insertions, 102 deletions
diff --git a/nss/gtests/common/common.gyp b/nss/gtests/common/common.gyp
deleted file mode 100644
index c501eba..0000000
--- a/nss/gtests/common/common.gyp
+++ /dev/null
@@ -1,35 +0,0 @@
-# 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/.
-{
- 'includes': [
- '../../coreconf/config.gypi',
- 'gtest.gypi',
- ],
- 'targets': [
- {
- 'target_name': 'gtests',
- 'type': 'executable',
- 'sources': [
- 'gtests.cc'
- ],
- 'dependencies': [
- '<(DEPTH)/exports.gyp:nss_exports',
- '<(DEPTH)/lib/nss/nss.gyp:nss3',
- '<(DEPTH)/lib/util/util.gyp:nssutil3',
- '<(DEPTH)/lib/smime/smime.gyp:smime3',
- '<(DEPTH)/gtests/google_test/google_test.gyp:gtest',
- '<(DEPTH)/cmd/lib/lib.gyp:sectool'
- ]
- }
- ],
- 'target_defaults': {
- 'include_dirs': [
- '../../gtests/google_test/gtest/include',
- '../../gtests/common'
- ],
- },
- 'variables': {
- 'module': 'nss'
- }
-}
diff --git a/nss/gtests/common/gtest.gypi b/nss/gtests/common/gtest.gypi
index c3bac32..c4865bb 100644
--- a/nss/gtests/common/gtest.gypi
+++ b/nss/gtests/common/gtest.gypi
@@ -2,10 +2,20 @@
# 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/.
{
- 'includes': [
- '../../coreconf/config.gypi'
- ],
'target_defaults': {
+ 'include_dirs': [
+ '<(DEPTH)/gtests/google_test/gtest/include',
+ '<(DEPTH)/gtests/common',
+ '<(DEPTH)/cpputil',
+ ],
+ 'cflags': [
+ '-Wsign-compare',
+ ],
+ 'xcode_settings': {
+ 'OTHER_CFLAGS': [
+ '-Wsign-compare',
+ ],
+ },
'conditions': [
['OS=="win"', {
'libraries': [
diff --git a/nss/gtests/common/gtests.cc b/nss/gtests/common/gtests.cc
index c51437c..bd5a97a 100644
--- a/nss/gtests/common/gtests.cc
+++ b/nss/gtests/common/gtests.cc
@@ -10,8 +10,12 @@
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
- NSS_NoDB_Init(nullptr);
- NSS_SetDomesticPolicy();
+ if (NSS_NoDB_Init(nullptr) != SECSuccess) {
+ return 1;
+ }
+ if (NSS_SetDomesticPolicy() != SECSuccess) {
+ return 1;
+ }
int rv = RUN_ALL_TESTS();
if (NSS_Shutdown() != SECSuccess) {
diff --git a/nss/gtests/common/manifest.mn b/nss/gtests/common/manifest.mn
index 9834e42..a40989b 100644
--- a/nss/gtests/common/manifest.mn
+++ b/nss/gtests/common/manifest.mn
@@ -11,7 +11,8 @@ CPPSRCS = \
$(NULL)
INCLUDES += -I$(CORE_DEPTH)/gtests/google_test/gtest/include \
- -I$(CORE_DEPTH)/gtests/common
+ -I$(CORE_DEPTH)/gtests/common \
+ -I$(CORE_DEPTH)/cpputil
REQUIRES = gtest
diff --git a/nss/gtests/common/scoped_ptrs.h b/nss/gtests/common/scoped_ptrs.h
deleted file mode 100644
index 2a96ee9..0000000
--- a/nss/gtests/common/scoped_ptrs.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=2 et sw=2 tw=80: */
-/* 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/. */
-
-#ifndef scoped_ptrs_h__
-#define scoped_ptrs_h__
-
-#include <memory>
-#include "cert.h"
-#include "keyhi.h"
-#include "pk11pub.h"
-
-namespace nss_test {
-
-struct ScopedDelete {
- void operator()(CERTCertificate* cert) { CERT_DestroyCertificate(cert); }
- void operator()(CERTCertificateList* list) {
- CERT_DestroyCertificateList(list);
- }
- void operator()(CERTCertList* list) { CERT_DestroyCertList(list); }
- void operator()(CERTSubjectPublicKeyInfo* spki) {
- SECKEY_DestroySubjectPublicKeyInfo(spki);
- }
- void operator()(PK11SlotInfo* slot) { PK11_FreeSlot(slot); }
- void operator()(PK11SymKey* key) { PK11_FreeSymKey(key); }
- void operator()(SECAlgorithmID* id) { SECOID_DestroyAlgorithmID(id, true); }
- void operator()(SECItem* item) { SECITEM_FreeItem(item, true); }
- void operator()(SECKEYPublicKey* key) { SECKEY_DestroyPublicKey(key); }
- void operator()(SECKEYPrivateKey* key) { SECKEY_DestroyPrivateKey(key); }
-};
-
-template <class T>
-struct ScopedMaybeDelete {
- void operator()(T* ptr) {
- if (ptr) {
- ScopedDelete del;
- del(ptr);
- }
- }
-};
-
-#define SCOPED(x) typedef std::unique_ptr<x, ScopedMaybeDelete<x> > Scoped##x
-
-SCOPED(CERTCertificate);
-SCOPED(CERTCertificateList);
-SCOPED(CERTCertList);
-SCOPED(CERTSubjectPublicKeyInfo);
-SCOPED(PK11SlotInfo);
-SCOPED(PK11SymKey);
-SCOPED(SECAlgorithmID);
-SCOPED(SECItem);
-SCOPED(SECKEYPublicKey);
-SCOPED(SECKEYPrivateKey);
-
-#undef SCOPED
-
-} // namespace nss_test
-
-#endif