-
Notifications
You must be signed in to change notification settings - Fork 23
Pytest tests and CI #58
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
base: main
Are you sure you want to change the base?
Changes from all commits
53a3358
0093076
d23c946
3b23acc
8d31993
86dea61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| name: Enforce coding style | ||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| style: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
|
|
||
| - name: Install Dependencies | ||
| run: | | ||
| sudo apt update -y | ||
| sudo apt install -y \ | ||
| uncrustify | ||
| - name: enforce style using uncrustify | ||
| run: | | ||
| uncrustify --replace -c uncrustify.cfg *.c *.h | ||
| git diff --exit-code |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| *~ | ||
| /*.o | ||
| /microcom | ||
| *.pyc | ||
|
|
||
| # autotools stuff | ||
| /.deps | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,7 @@ static struct termios sots; /* old stdout/in termios settings to restore */ | |
|
|
||
| struct ios_ops *ios; | ||
| int debug; | ||
| int quiet; | ||
|
|
||
| void init_terminal(void) | ||
| { | ||
|
|
@@ -98,6 +99,7 @@ void main_usage(int exitcode, char *str, char *dev) | |
| " default: (%s:%x:%x)\n" | ||
| " -f, --force ignore existing lock file\n" | ||
| " -d, --debug output debugging info\n" | ||
| " -q, --quiet do not print status information to stdout\n" | ||
| " -l, --logfile=<logfile> log output to <logfile>\n" | ||
| " -o, --listenonly Do not modify local terminal, do not send input\n" | ||
| " from stdin\n" | ||
|
|
@@ -136,6 +138,7 @@ int main(int argc, char *argv[]) | |
| { "telnet", required_argument, NULL, 't'}, | ||
| { "can", required_argument, NULL, 'c'}, | ||
| { "debug", no_argument, NULL, 'd' }, | ||
| { "quiet", no_argument, NULL, 'q' }, | ||
| { "force", no_argument, NULL, 'f' }, | ||
| { "logfile", required_argument, NULL, 'l'}, | ||
| { "listenonly", no_argument, NULL, 'o'}, | ||
|
|
@@ -144,54 +147,57 @@ int main(int argc, char *argv[]) | |
| { }, | ||
| }; | ||
|
|
||
| while ((opt = getopt_long(argc, argv, "hp:s:t:c:dfl:oi:a:e:v", long_options, NULL)) != -1) { | ||
| while ((opt = getopt_long(argc, argv, "hp:s:t:c:dqfl:oi:a:e:v", long_options, NULL)) != -1) { | ||
| switch (opt) { | ||
| case '?': | ||
| main_usage(1, "", ""); | ||
| break; | ||
| case 'h': | ||
| main_usage(0, "", ""); | ||
| break; | ||
| case 'v': | ||
| printf("%s\n", PACKAGE_VERSION); | ||
| exit(EXIT_SUCCESS); | ||
| break; | ||
| case 'p': | ||
| device = optarg; | ||
| break; | ||
| case 's': | ||
| current_speed = strtoul(optarg, NULL, 0); | ||
| break; | ||
| case 't': | ||
| telnet = 1; | ||
| hostport = optarg; | ||
| break; | ||
| case 'c': | ||
| can = 1; | ||
| interfaceid = optarg; | ||
| break; | ||
| case 'f': | ||
| opt_force = 1; | ||
| break; | ||
| case 'd': | ||
| debug = 1; | ||
| break; | ||
| case 'l': | ||
| logfile = optarg; | ||
| break; | ||
| case 'o': | ||
| listenonly = 1; | ||
| break; | ||
| case 'a': | ||
| answerback = optarg; | ||
| break; | ||
| case 'e': | ||
| if (strlen(optarg) != 1) { | ||
| fprintf(stderr, "Option -e requires a single character argument.\n"); | ||
| exit(EXIT_FAILURE); | ||
| } | ||
| escape_char = *optarg; | ||
| break; | ||
| case '?': | ||
| main_usage(1, "", ""); | ||
| break; | ||
| case 'h': | ||
| main_usage(0, "", ""); | ||
| break; | ||
| case 'v': | ||
| printf("%s\n", PACKAGE_VERSION); | ||
| exit(EXIT_SUCCESS); | ||
| break; | ||
| case 'p': | ||
| device = optarg; | ||
| break; | ||
| case 's': | ||
| current_speed = strtoul(optarg, NULL, 0); | ||
| break; | ||
| case 't': | ||
| telnet = 1; | ||
| hostport = optarg; | ||
| break; | ||
| case 'c': | ||
| can = 1; | ||
| interfaceid = optarg; | ||
| break; | ||
| case 'f': | ||
| opt_force = 1; | ||
| break; | ||
| case 'd': | ||
| debug = 1; | ||
| break; | ||
| case 'q': | ||
| quiet = 1; | ||
| break; | ||
| case 'l': | ||
| logfile = optarg; | ||
| break; | ||
| case 'o': | ||
| listenonly = 1; | ||
| break; | ||
| case 'a': | ||
| answerback = optarg; | ||
| break; | ||
| case 'e': | ||
| if (strlen(optarg) != 1) { | ||
| fprintf(stderr, "Option -e requires a single character argument.\n"); | ||
| exit(EXIT_FAILURE); | ||
| } | ||
| escape_char = *optarg; | ||
| break; | ||
|
Comment on lines
+152
to
+200
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This mixes a formatting change with a code change. It would be great to only have the + case 'q':
+ quiet = 1;
+ break;In this commit.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I originally based this on all the three dependent branches and only haphazardly rebased to main to avoid making too large a pull request. |
||
| } | ||
| } | ||
|
|
||
|
|
@@ -239,8 +245,8 @@ int main(int argc, char *argv[]) | |
| ios->set_flow(ios, current_flow); | ||
|
|
||
| if (!listenonly) { | ||
| printf("Escape character: Ctrl-%c\n", escape_char); | ||
| printf("Type the escape character to get to the prompt.\n"); | ||
| msg_printf("Escape character: Ctrl-%c\n", escape_char); | ||
| msg_printf("Type the escape character to get to the prompt.\n"); | ||
|
|
||
| /* Now deal with the local terminal side */ | ||
| tcgetattr(STDIN_FILENO, &sots); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import os | ||
| from pathlib import Path | ||
| import shlex | ||
| import pytest | ||
|
|
||
|
|
||
| def pytest_sessionstart(session): | ||
| # run tests in toplevel directory always, not in test/ | ||
| os.chdir(Path(__file__).resolve().parent.parent) | ||
|
|
||
|
|
||
| def pytest_addoption(parser): | ||
| parser.addoption( | ||
| "--cmd", | ||
| action="store", | ||
| default="./microcom", | ||
| help="Command used to invoke microcom" | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def cmd(pytestconfig): | ||
| cmd = pytestconfig.getoption("--cmd") | ||
| return shlex.split(cmd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#55 explicitly zeros
debug. Not zeroingquietnow aligns it with the code as-is, but since #55 should be merged first I think this should be:int quiet = 0;There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it's an artifact from my attempt to split up what was originally a single series.
quietis zero-initialized on the "single series" branch to which I can update this pr once the dependent PRs are merged.I suppose unitialized globals are more a bad style practice than actual reliance on unitialized memory, at least on linux where they're zero-initialized as part of the bss (in contrast to locals which are stack-allocated and not automatically initialized).
Anyway, yes this will be taken care of :)