|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ |
|
3 */ |
|
4 |
|
5 /* File locked partial MAR file patch apply failure test */ |
|
6 |
|
7 function run_test() { |
|
8 if (!shouldRunServiceTest()) { |
|
9 return; |
|
10 } |
|
11 |
|
12 setupTestCommon(); |
|
13 gTestFiles = gTestFilesPartialSuccess; |
|
14 gTestDirs = gTestDirsPartialSuccess; |
|
15 setTestFilesAndDirsForFailure(); |
|
16 setupUpdaterTest(FILE_PARTIAL_MAR, false, false); |
|
17 |
|
18 // Exclusively lock an existing file so it is in use during the update. |
|
19 let helperBin = getTestDirFile(FILE_HELPER_BIN); |
|
20 let helperDestDir = getApplyDirFile("a/b/"); |
|
21 helperBin.copyTo(helperDestDir, FILE_HELPER_BIN); |
|
22 helperBin = getApplyDirFile("a/b/" + FILE_HELPER_BIN); |
|
23 // Strip off the first two directories so the path has to be from the helper's |
|
24 // working directory. |
|
25 let lockFileRelPath = gTestFiles[2].relPathDir.split("/"); |
|
26 lockFileRelPath = lockFileRelPath.slice(2); |
|
27 lockFileRelPath = lockFileRelPath.join("/") + "/" + gTestFiles[2].fileName; |
|
28 let args = [getApplyDirPath() + "a/b/", "input", "output", "-s", |
|
29 HELPER_SLEEP_TIMEOUT, lockFileRelPath]; |
|
30 let lockFileProcess = AUS_Cc["@mozilla.org/process/util;1"]. |
|
31 createInstance(AUS_Ci.nsIProcess); |
|
32 lockFileProcess.init(helperBin); |
|
33 lockFileProcess.run(false, args, args.length); |
|
34 |
|
35 setupAppFilesAsync(); |
|
36 } |
|
37 |
|
38 function setupAppFilesFinished() { |
|
39 do_timeout(TEST_HELPER_TIMEOUT, waitForHelperSleep); |
|
40 } |
|
41 |
|
42 function doUpdate() { |
|
43 runUpdateUsingService(STATE_PENDING_SVC, STATE_FAILED); |
|
44 } |
|
45 |
|
46 function checkUpdateFinished() { |
|
47 setupHelperFinish(); |
|
48 } |
|
49 |
|
50 function checkUpdate() { |
|
51 checkFilesAfterUpdateFailure(); |
|
52 checkUpdateLogContains(ERR_UNABLE_OPEN_DEST); |
|
53 checkCallbackServiceLog(); |
|
54 } |