Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test time #120

Merged
merged 29 commits into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift click to select a range
5d9c349
Added first tests for linux kernel downloader, codecov action init
0xricksanchez Oct 17, 2022
1d52ae5
flake8
0xricksanchez Oct 17, 2022
0679f39
rm unnecessary conf
0xricksanchez Oct 17, 2022
f0c4c89
tests for kernel_unpacker
0xricksanchez Oct 17, 2022
660e764
merge main
0xricksanchez Oct 18, 2022
bd5e795
some refactoring
0xricksanchez Oct 18, 2022
0be17c9
docker_runner tests
0xricksanchez Oct 18, 2022
bf7dfd0
docker_runner tests
0xricksanchez Oct 18, 2022
7579ab0
wip kernel_builder tets
0xricksanchez Oct 20, 2022
c2f9d42
wip kernel_builder tets
0xricksanchez Oct 20, 2022
353343e
fixed sudo test
0xricksanchez Oct 20, 2022
abfce60
more tests
0xricksanchez Oct 21, 2022
2c737ff
more tests
0xricksanchez Oct 21, 2022
4a9d20c
more tests
0xricksanchez Oct 21, 2022
e2f71c1
linting, merge main
0xricksanchez Oct 21, 2022
592eed5
Merge branch 'main' into tests
0xricksanchez Oct 21, 2022
e49198d
.
0xricksanchez Oct 22, 2022
12598d9
more tests
0xricksanchez Oct 22, 2022
145e3a5
more tests
0xricksanchez Oct 22, 2022
23a34c6
more tests
0xricksanchez Oct 22, 2022
b2249a9
more tests
0xricksanchez Oct 23, 2022
5f98448
Merge branch 'main' into tests
0xricksanchez Oct 23, 2022
fda2749
more tests
0xricksanchez Oct 23, 2022
8fb4b92
Merge branch 'main' into tests
0xricksanchez Oct 25, 2022
a492bcb
more tests
0xricksanchez Oct 25, 2022
9064c89
more tests
0xricksanchez Oct 25, 2022
405cd92
more tests
0xricksanchez Oct 25, 2022
08fc6c6
more tests
0xricksanchez Oct 25, 2022
1ad62c1
more tests
0xricksanchez Oct 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed sudo test
  • Loading branch information
0xricksanchez committed Oct 20, 2022
commit 353343e5dacfd19957a960e64199defb22e03754
4 changes: 2 additions & 2 deletions src/kernel_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 2,7 @@

import re
import time
from os import getuid
import os
from pathlib import Path
import subprocess as sp
from invoke.exceptions import UnexpectedExit
Expand Down Expand Up @@ -41,7 41,7 @@ def __init__(self, **kwargs) -> None:

@staticmethod
def make_sudo(cmd: str) -> str:
if getuid() == 0:
if os.getuid() == 0:
return f"sudo {cmd}"
else:
return cmd
Expand Down
17 changes: 9 additions & 8 deletions src/tests/test_kernel_builder.py
Original file line number Diff line number Diff line change
@@ -1,9 1,9 @@
import os
from ..kernel_builder import KernelBuilder
from pathlib import Path
import collections
import configparser
from unittest.mock import patch
import os


USER_INI = Path("configs/user.ini")
Expand All @@ -22,15 22,16 @@ def are_lists_equal(x, y) -> bool:
return collections.Counter(x) == collections.Counter(y)


def test_make_sudo_fail() -> None:
assert KernelBuilder.make_sudo("test") == "test"
@patch("os.getuid", return_value=1)
def test_make_sudo_user(self) -> None:
kb = KernelBuilder(**{"kroot": "foo"})
assert kb.make_sudo("test") == "test"


@patch("os.getuid", return_value=42)
def test_make_sudo_success(self) -> None:
assert os.getuid() == 42
# kb = KernelBuilder(**{"kroot": "foo"})
# assert kb.make_sudo("test") == "sudo test"
@patch("os.getuid", return_value=0)
def test_make_sudo_root(self) -> None:
kb = KernelBuilder(**{"kroot": "foo"})
assert kb.make_sudo("test") == "sudo test"


def test_custom_args() -> None:
Expand Down