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

[ecnconfig] Allow ecn unit test to run without sudo #1390

Merged
merged 2 commits into from
Jan 29, 2021
Merged
Changes from 1 commit
Commits
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
6 changes: 3 additions & 3 deletions scripts/ecnconfig
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class EcnConfig(object):
return result

def set_wred_threshold(self, profile, threshold, value):
if os.geteuid() != 0:
if os.geteuid() != 0 and os.environ.get("UTILITIES_UNIT_TESTING", "0") != "2":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract lines into a function?

        if os.geteuid() != 0 and os.environ.get("UTILITIES_UNIT_TESTING", "0") != "2":
            sys.exit("Root privileges required for this operation")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

sys.exit("Root privileges required for this operation")

field = WRED_CONFIG_FIELDS[threshold]
Expand All @@ -179,7 +179,7 @@ class EcnConfig(object):
json.dump(prof_table, fd)

def set_wred_prob(self, profile, drop_color, value):
if os.geteuid() != 0:
if os.geteuid() != 0 and os.environ.get("UTILITIES_UNIT_TESTING", "0") != "2":
sys.exit("Root privileges required for this operation")

field = WRED_CONFIG_FIELDS[drop_color]
Expand Down Expand Up @@ -227,7 +227,7 @@ class EcnQ(object):
)

def set(self, enable):
if os.geteuid() != 0:
if os.geteuid() != 0 and os.environ.get("UTILITIES_UNIT_TESTING", "0") != "2":
sys.exit("Root privileges required for this operation")
for queue in self.queues:
if self.verbose:
Expand Down