-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
""" | ||
Verify that alr can run with no HOME set, or with it set to an | ||
unwritable/nonexistent directory. | ||
NOTE: This same test is duplicated to be run under docker as a regular user. | ||
""" | ||
|
||
import os | ||
from drivers.alr import run_alr | ||
|
||
|
||
def check_no_home(): | ||
# Verify that alr is using the fallback home directory. | ||
p = run_alr("--format", "version") | ||
assert """{ | ||
"key": "home folder", | ||
"value": "/tmp" | ||
}""" in p.out, "Unexpected output: " + p.out | ||
|
||
|
||
# Remove HOME | ||
os.environ.pop("HOME", None) | ||
check_no_home() | ||
|
||
# Set HOME to a nonexistent directory | ||
fake_home = "/tmp/fake_home_for_alr" | ||
assert not os.path.exists(fake_home) | ||
os.environ["HOME"] = fake_home | ||
check_no_home() | ||
|
||
# Set HOME to an unwritable directory | ||
# Under our docker, we should be a regular user and this should succeed | ||
os.makedirs(fake_home) | ||
os.chmod(fake_home, 0o444) | ||
check_no_home() | ||
# Cleanup | ||
os.chmod(fake_home, 0o777) | ||
os.rmdir(fake_home) | ||
|
||
|
||
print("SUCCESS") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
driver: docker-wrapper | ||
build_mode: both | ||
control: | ||
- [SKIP, "skip_docker", "Test is Docker-only"] | ||
- [SKIP, "skip_unix", "Test is Unix-only"] | ||
indexes: | ||
compiler_only_index: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
""" | ||
Verify that alr can run with no HOME set, or with it set to an | ||
unwritable/nonexistent directory. | ||
NOTE: This same test is duplicated to be run under docker as a regular user. | ||
""" | ||
|
||
import os | ||
from drivers.alr import run_alr | ||
|
||
|
||
def check_no_home(): | ||
# Verify that alr is using the fallback home directory. | ||
p = run_alr("--format", "version") | ||
assert """{ | ||
"key": "home folder", | ||
"value": "/tmp" | ||
}""" in p.out, "Unexpected output: " + p.out | ||
|
||
|
||
# Remove HOME | ||
os.environ.pop("HOME", None) | ||
check_no_home() | ||
|
||
# Set HOME to a nonexistent directory | ||
fake_home = "/tmp/fake_home_for_alr" | ||
assert not os.path.exists(fake_home) | ||
os.environ["HOME"] = fake_home | ||
check_no_home() | ||
|
||
# Set HOME to an unwritable directory | ||
# This will fail if running under root, in which case we skip this part. | ||
# This is tested properly under docker | ||
if os.getuid() != 0: | ||
os.makedirs(fake_home) | ||
os.chmod(fake_home, 0o444) | ||
check_no_home() | ||
# Cleanup | ||
os.chmod(fake_home, 0o777) | ||
os.rmdir(fake_home) | ||
|
||
|
||
print("SUCCESS") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
driver: python-script | ||
build_mode: both | ||
control: | ||
- [SKIP, "skip_unix", "Test is Unix-only"] | ||
indexes: | ||
compiler_only_index: {} |