summaryrefslogtreecommitdiffstats
path: root/toolkit/profile
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-02-25 15:07:00 -0500
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-14 12:55:19 +0200
commiteb70e6e3d0bff11c25f14b1196025791bf2308fb (patch)
tree5ef4ce17db83c74d7b05ec12c8f59e095a6dd5bd /toolkit/profile
parent32ead795290b3399d56b4708fc75b77d296f6a1a (diff)
downloadUXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.gz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.lz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.xz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.zip
Issue #439 - Remove tests from toolkit/
Diffstat (limited to 'toolkit/profile')
-rw-r--r--toolkit/profile/gtest/TestProfileLock.cpp116
-rw-r--r--toolkit/profile/gtest/moz.build16
-rw-r--r--toolkit/profile/moz.build24
-rw-r--r--toolkit/profile/test/.eslintrc.js7
-rw-r--r--toolkit/profile/test/chrome.ini3
-rw-r--r--toolkit/profile/test/test_create_profile.xul134
6 files changed, 4 insertions, 296 deletions
diff --git a/toolkit/profile/gtest/TestProfileLock.cpp b/toolkit/profile/gtest/TestProfileLock.cpp
deleted file mode 100644
index ac5117d74..000000000
--- a/toolkit/profile/gtest/TestProfileLock.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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 "gtest/gtest.h"
-
-#include <sys/eventfd.h>
-#include <sched.h>
-
-#include "nsCOMPtr.h"
-#include "nsIFile.h"
-#include "nsProfileLock.h"
-#include "nsString.h"
-
-static void CleanParentLock(const char *tmpdir)
-{
- // nsProfileLock doesn't clean up all its files
- char permanent_lockfile[] = "/.parentlock";
-
- char * parentlock_name;
- size_t parentlock_name_size = strlen(tmpdir) + strlen(permanent_lockfile) + 1;
- parentlock_name = (char*)malloc(parentlock_name_size);
-
- strcpy(parentlock_name, tmpdir);
- strcat(parentlock_name, permanent_lockfile);
-
- EXPECT_EQ(0, unlink(parentlock_name));
- EXPECT_EQ(0, rmdir(tmpdir));
- free(parentlock_name);
-}
-
-TEST(ProfileLock, BasicLock)
-{
- char templ[] = "/tmp/profilelocktest.XXXXXX";
- char * tmpdir = mkdtemp(templ);
- ASSERT_NE(tmpdir, nullptr);
-
- // This scope exits so the nsProfileLock destructor
- // can clean up the files it leaves in tmpdir.
- {
- nsProfileLock myLock;
- nsresult rv;
- nsCOMPtr<nsIFile> dir(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv));
- ASSERT_EQ(NS_SUCCEEDED(rv), true);
-
- rv = dir->InitWithNativePath(nsCString(tmpdir));
- ASSERT_EQ(NS_SUCCEEDED(rv), true);
-
- rv = myLock.Lock(dir, nullptr);
- EXPECT_EQ(NS_SUCCEEDED(rv), true);
- }
-
- CleanParentLock(tmpdir);
-}
-
-TEST(ProfileLock, RetryLock)
-{
- char templ[] = "/tmp/profilelocktest.XXXXXX";
- char * tmpdir = mkdtemp(templ);
- ASSERT_NE(tmpdir, nullptr);
-
- {
- nsProfileLock myLock;
- nsProfileLock myLock2;
- nsresult rv;
- nsCOMPtr<nsIFile> dir(do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv));
- ASSERT_EQ(NS_SUCCEEDED(rv), true);
-
- rv = dir->InitWithNativePath(nsCString(tmpdir));
- ASSERT_EQ(NS_SUCCEEDED(rv), true);
-
- int eventfd_fd = eventfd(0, 0);
- ASSERT_GE(eventfd_fd, 0);
-
- // fcntl advisory locks are per process, so it's hard
- // to avoid using fork here.
- pid_t childpid = fork();
-
- if (childpid) {
- // parent
-
- // blocking read causing us to lose the race
- eventfd_t value;
- EXPECT_EQ(0, eventfd_read(eventfd_fd, &value));
-
- rv = myLock2.Lock(dir, nullptr);
- EXPECT_EQ(NS_ERROR_FILE_ACCESS_DENIED, rv);
-
- // kill the child
- EXPECT_EQ(0, kill(childpid, SIGTERM));
-
- // reap zombie (required to collect the lock)
- int status;
- EXPECT_EQ(childpid, waitpid(childpid, &status, 0));
-
- rv = myLock2.Lock(dir, nullptr);
- EXPECT_EQ(NS_SUCCEEDED(rv), true);
- } else {
- // child
- rv = myLock.Lock(dir, nullptr);
- ASSERT_EQ(NS_SUCCEEDED(rv), true);
-
- // unblock parent
- EXPECT_EQ(0, eventfd_write(eventfd_fd, 1));
-
- // parent will kill us
- for (;;)
- sleep(1);
- }
-
- close(eventfd_fd);
- }
-
- CleanParentLock(tmpdir);
-}
diff --git a/toolkit/profile/gtest/moz.build b/toolkit/profile/gtest/moz.build
deleted file mode 100644
index 51b420e19..000000000
--- a/toolkit/profile/gtest/moz.build
+++ /dev/null
@@ -1,16 +0,0 @@
-# -*- 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/.
-
-LOCAL_INCLUDES += [
- '..',
-]
-
-if CONFIG['OS_ARCH'] == 'Linux':
- UNIFIED_SOURCES += [
- 'TestProfileLock.cpp',
- ]
-
-FINAL_LIBRARY = 'xul-gtest'
diff --git a/toolkit/profile/moz.build b/toolkit/profile/moz.build
index b2383a871..0a84b8c69 100644
--- a/toolkit/profile/moz.build
+++ b/toolkit/profile/moz.build
@@ -4,11 +4,6 @@
# 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/.
-MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
-
-if CONFIG['ENABLE_TESTS']:
- DIRS += ['gtest']
-
XPIDL_SOURCES += [
'nsIProfileMigrator.idl',
'nsIProfileUnlocker.idl',
@@ -18,26 +13,15 @@ XPIDL_SOURCES += [
XPIDL_MODULE = 'toolkitprofile'
-UNIFIED_SOURCES += [
- 'nsProfileLock.cpp'
-]
+UNIFIED_SOURCES += ['nsProfileLock.cpp']
if CONFIG['OS_ARCH'] == 'WINNT':
- UNIFIED_SOURCES += [
- 'ProfileUnlockerWin.cpp'
- ]
+ UNIFIED_SOURCES += ['ProfileUnlockerWin.cpp']
-UNIFIED_SOURCES += [
- 'nsToolkitProfileService.cpp'
-]
+UNIFIED_SOURCES += ['nsToolkitProfileService.cpp']
-LOCAL_INCLUDES += [
- '../xre',
-]
+LOCAL_INCLUDES += ['../xre']
FINAL_LIBRARY = 'xul'
JAR_MANIFESTS += ['jar.mn']
-
-with Files('**'):
- BUG_COMPONENT = ('Toolkit', 'Startup and Profile System')
diff --git a/toolkit/profile/test/.eslintrc.js b/toolkit/profile/test/.eslintrc.js
deleted file mode 100644
index 4e6d4bcf0..000000000
--- a/toolkit/profile/test/.eslintrc.js
+++ /dev/null
@@ -1,7 +0,0 @@
-"use strict";
-
-module.exports = {
- "extends": [
- "../../../testing/mochitest/chrome.eslintrc.js"
- ]
-};
diff --git a/toolkit/profile/test/chrome.ini b/toolkit/profile/test/chrome.ini
deleted file mode 100644
index e21c1022e..000000000
--- a/toolkit/profile/test/chrome.ini
+++ /dev/null
@@ -1,3 +0,0 @@
-[DEFAULT]
-
-[test_create_profile.xul]
diff --git a/toolkit/profile/test/test_create_profile.xul b/toolkit/profile/test/test_create_profile.xul
deleted file mode 100644
index 040b1256b..000000000
--- a/toolkit/profile/test/test_create_profile.xul
+++ /dev/null
@@ -1,134 +0,0 @@
-<?xml version="1.0"?>
-<?xml-stylesheet type="text/css" href="chrome://global/skin"?>
-<?xml-stylesheet type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=543854
--->
-<window title="Mozilla Bug 543854"
- xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
- <script type="application/javascript"
- src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-
- <!-- test results are displayed in the html:body -->
- <body xmlns="http://www.w3.org/1999/xhtml">
- <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=543854"
- target="_blank">Mozilla Bug 543854</a>
- </body>
-
- <!-- test code goes here -->
- <script type="application/javascript">
- <![CDATA[
-
- /** Test for Bug 543854 **/
-
- SimpleTest.waitForExplicitFinish();
-
- const Cc = Components.classes;
- const Ci = Components.interfaces;
-
- const ASCIIName = "myprofile";
- const UnicodeName = "\u09A0\u09BE\u0995\u09C1\u09B0"; // A Bengali name
-
- var gDirService;
- var gIOService;
- var gProfileService;
-
- var gDefaultLocalProfileParent;
-
- gDirService = Cc["@mozilla.org/file/directory_service;1"].
- getService(Ci.nsIProperties);
-
- gIOService = Cc["@mozilla.org/network/io-service;1"].
- getService(Ci.nsIIOService);
-
- gProfileService = Cc["@mozilla.org/toolkit/profile-service;1"].
- getService(Ci.nsIToolkitProfileService);
-
- gDefaultLocalProfileParent = gDirService.get("DefProfLRt", Ci.nsIFile);
-
- createProfile(ASCIIName);
- createProfile(UnicodeName);
- SimpleTest.finish();
-
-/**
- * Read the contents of an nsIFile. Throws on error.
-
- * @param file an nsIFile instance.
- * @return string contents.
- */
-function readFile(file) {
- let fstream = Cc["@mozilla.org/network/file-input-stream;1"].
- createInstance(Ci.nsIFileInputStream);
- let sstream = Cc["@mozilla.org/scriptableinputstream;1"].
- createInstance(Components.interfaces.nsIScriptableInputStream);
-
- const RO = 0x01;
- const READ_OTHERS = 4;
-
- fstream.init(file, RO, READ_OTHERS, 0);
- sstream.init(fstream);
- let out = sstream.read(sstream.available());
- sstream.close();
- fstream.close();
- return out;
-}
-
-function checkBounds(lowerBound, value, upperBound) {
- ok(lowerBound <= value, "value " + value +
- " is above lower bound " + lowerBound);
- ok(upperBound >= value, "value " + value +
- " is within upper bound " + upperBound);
-}
-
-function createProfile(profileName) {
- // Filesystem precision is lower than Date precision.
- let lowerBound = Date.now() - 1000;
-
- let profile = gProfileService.createProfile(null, profileName);
-
- // check that the directory was created
- isnot(profile, null, "Profile " + profileName + " created");
-
- let profileDir = profile.rootDir;
-
- ok(profileDir.exists(), "Profile dir created");
- ok(profileDir.isDirectory(), "Profile dir is a directory");
-
- let profileDirPath = profileDir.path;
-
- is(profileDirPath.substr(profileDirPath.length - profileName.length),
- profileName, "Profile dir has expected name");
-
- // Ensure that our timestamp file was created.
- let jsonFile = profileDir.clone();
- jsonFile.append("times.json");
- ok(jsonFile.path, "Path is " + jsonFile.path);
- ok(jsonFile.exists(), "Times file was created");
- ok(jsonFile.isFile(), "Times file is a file");
- let json = JSON.parse(readFile(jsonFile));
-
- let upperBound = Date.now() + 1000;
-
- let created = json.created;
- ok(created, "created is set");
-
- // Check against real clock time.
- checkBounds(lowerBound, created, upperBound);
-
- // Clean up the profile before local profile test.
- profile.remove(true);
-
- // Create with non-null aRootDir
- profile = gProfileService.createProfile(profileDir, profileName);
-
- let localProfileDir = profile.localDir;
- ok(gDefaultLocalProfileParent.contains(localProfileDir, false),
- "Local profile dir created in DefProfLRt");
-
- // Clean up the profile.
- profile.remove(true);
-}
-
- ]]>
- </script>
-</window>