Skip to content

Commit 484af02

Browse files
authored
Merge branch 'master' into cicd/group-test-output
2 parents 46cad73 + 77d8deb commit 484af02

22 files changed

+2028
-143
lines changed

.clang-format

+1
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ ForEachMacros:
2424
- hlist_for_each_entry
2525
- rb_list_foreach
2626
- rb_list_foreach_safe
27+
SpaceBeforeParens: ControlStatementsExceptForEachMacros

.editorconfig

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
trim_trailing_whitespace = true
7+
8+
[Makefile]
9+
indent_style = tab
10+
indent_size = 4
11+
max_line_length = 80
12+
13+
[**/*.[ch]]
14+
indent_style = space
15+
indent_size = 4
16+
max_line_length = 80
17+
18+
[{**/*.py,.ci/*}]
19+
indent_style = space
20+
indent_size = 4
21+
22+
[{scripts/*,.github/workflows/*}]
23+
indent_style = space
24+
indent_size = 2

.github/workflows/main.yml

+14-14
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,33 @@ jobs:
1010
- uses: webfactory/[email protected]
1111
continue-on-error: true
1212
with:
13-
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
13+
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
1414
- name: install-dependencies
1515
run: |
16-
.ci/check-sanity.sh
17-
sudo apt-get update
18-
sudo apt-get -q -y install build-essential cppcheck
16+
.ci/check-sanity.sh
17+
sudo apt-get update
18+
sudo apt-get -q -y install build-essential cppcheck
1919
- name: make
2020
run: |
21-
git clone [email protected]:sysprog21/lab0-c-private || echo "No provisioning profile found"
22-
.ci/check-provisioning.sh
23-
make
21+
git clone [email protected]:sysprog21/lab0-c-private || echo "No provisioning profile found"
22+
.ci/check-provisioning.sh
23+
make
2424
- name: make check
2525
run: |
26-
make check || (cat scripts/weeping.raw ; exit 1)
27-
cat scripts/kirby.raw
26+
make check || (cat scripts/weeping.raw ; exit 1)
27+
cat scripts/kirby.raw
2828
- name: make test
2929
run: |
30-
make test || (cat scripts/weeping.raw ; exit 1)
31-
cat scripts/kirby.raw
30+
make test || (cat scripts/weeping.raw ; exit 1)
31+
cat scripts/kirby.raw
3232
3333
coding-style:
3434
runs-on: ubuntu-24.04
3535
steps:
3636
- uses: actions/checkout@v4
3737
- name: coding convention
3838
run: |
39-
sudo apt-get install -q -y clang-format-18
40-
.ci/check-newline.sh
41-
.ci/check-format.sh
39+
sudo apt-get install -q -y clang-format-18
40+
.ci/check-newline.sh
41+
.ci/check-format.sh
4242
shell: bash

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
qtest
2+
fmtscan
23
*.o
34
*.o.d
45
*.dSYM

Makefile

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ CFLAGS += -Wvla
66

77
GIT_HOOKS := .git/hooks/applied
88
DUT_DIR := dudect
9-
all: $(GIT_HOOKS) qtest
9+
all: $(GIT_HOOKS) qtest fmtscan
1010

1111
tid := 0
1212

@@ -53,6 +53,10 @@ qtest: $(OBJS)
5353
$(VECHO) " CC\t$@\n"
5454
$(Q)$(CC) -o $@ $(CFLAGS) -c -MMD -MF .$@.d $<
5555

56+
fmtscan: tools/fmtscan.c
57+
$(VECHO) " CC+LD\t$@\n"
58+
$(Q)$(CC) -o $@ $(CFLAGS) $< -lrt -lpthread
59+
5660
check: qtest
5761
./$< -v 3 -f traces/trace-eg.cmd
5862

@@ -80,7 +84,7 @@ valgrind: valgrind_existence
8084
@echo "scripts/driver.py -p $(patched_file) --valgrind -t <tid>"
8185

8286
clean:
83-
rm -f $(OBJS) $(deps) *~ qtest /tmp/qtest.*
87+
rm -f $(OBJS) $(deps) *~ qtest /tmp/qtest.* fmtscan
8488
rm -rf .$(DUT_DIR)
8589
rm -rf *.dSYM
8690
(cd traces; rm -f *~)

console.c

+41-30
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ static char **parse_args(char *line, int *argcp)
144144
*dst++ = c;
145145
}
146146
}
147+
/* Let the last substring is null-terminated */
148+
*dst++ = '\0';
147149

148150
/* Now assemble into array of strings */
149151
char **argv = calloc_or_fail(argc, sizeof(char *), "parse_args");
@@ -158,12 +160,43 @@ static char **parse_args(char *line, int *argcp)
158160
return argv;
159161
}
160162

163+
/* Handles forced console termination for record_error and do_quit */
164+
static bool force_quit(int argc, char *argv[])
165+
{
166+
cmd_element_t *c = cmd_list;
167+
bool ok = true;
168+
while (c) {
169+
cmd_element_t *ele = c;
170+
c = c->next;
171+
free_block(ele, sizeof(cmd_element_t));
172+
}
173+
174+
param_element_t *p = param_list;
175+
while (p) {
176+
param_element_t *ele = p;
177+
p = p->next;
178+
free_block(ele, sizeof(param_element_t));
179+
}
180+
181+
while (buf_stack)
182+
pop_file();
183+
184+
for (int i = 0; i < quit_helper_cnt; i++) {
185+
ok = ok && quit_helpers[i](argc, argv);
186+
}
187+
188+
quit_flag = true;
189+
return ok;
190+
}
191+
161192
static void record_error()
162193
{
163194
err_cnt++;
164195
if (err_cnt >= err_limit) {
165-
report(1, "Error limit exceeded. Stopping command execution");
166-
quit_flag = true;
196+
report(
197+
1,
198+
"Error limit exceeded. Stopping command execution, and quitting");
199+
force_quit(0, NULL);
167200
}
168201
}
169202

@@ -224,30 +257,7 @@ void set_echo(bool on)
224257
/* Built-in commands */
225258
static bool do_quit(int argc, char *argv[])
226259
{
227-
cmd_element_t *c = cmd_list;
228-
bool ok = true;
229-
while (c) {
230-
cmd_element_t *ele = c;
231-
c = c->next;
232-
free_block(ele, sizeof(cmd_element_t));
233-
}
234-
235-
param_element_t *p = param_list;
236-
while (p) {
237-
param_element_t *ele = p;
238-
p = p->next;
239-
free_block(ele, sizeof(param_element_t));
240-
}
241-
242-
while (buf_stack)
243-
pop_file();
244-
245-
for (int i = 0; i < quit_helper_cnt; i++) {
246-
ok = ok && quit_helpers[i](argc, argv);
247-
}
248-
249-
quit_flag = true;
250-
return ok;
260+
return force_quit(argc, argv);
251261
}
252262

253263
static bool do_help(int argc, char *argv[])
@@ -345,7 +355,7 @@ static bool do_option(int argc, char *argv[])
345355
static bool do_source(int argc, char *argv[])
346356
{
347357
if (argc < 2) {
348-
report(1, "No source file given");
358+
report(1, "No source file given. Use 'source <file>'.");
349359
return false;
350360
}
351361

@@ -360,14 +370,15 @@ static bool do_source(int argc, char *argv[])
360370
static bool do_log(int argc, char *argv[])
361371
{
362372
if (argc < 2) {
363-
report(1, "No log file given");
373+
report(1, "No log file given. Use 'log <file>'.");
364374
return false;
365375
}
366376

367377
bool result = set_logfile(argv[1]);
368378
if (!result)
369379
report(1, "Couldn't open log file '%s'", argv[1]);
370380

381+
printf("Logging enabled: %s\n", argv[1]);
371382
return result;
372383
}
373384

@@ -427,7 +438,7 @@ void init_cmd()
427438
"Display or set options. See 'Options' section for details",
428439
"[name val]");
429440
ADD_COMMAND(quit, "Exit program", "");
430-
ADD_COMMAND(source, "Read commands from source file", "");
441+
ADD_COMMAND(source, "Read commands from source file", "file");
431442
ADD_COMMAND(log, "Copy output to file", "file");
432443
ADD_COMMAND(time, "Time command execution", "cmd arg ...");
433444
ADD_COMMAND(web, "Read commands from builtin web server", "[port]");
@@ -577,7 +588,7 @@ static int cmd_select(int nfds,
577588
FD_ZERO(readfds);
578589
FD_SET(infd, readfds);
579590

580-
/* If web not ready listen */
591+
/* If web_fd is available, add to readfds */
581592
if (web_fd != -1)
582593
FD_SET(web_fd, readfds);
583594

dudect/fixture.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static bool report(void)
8484
double max_tau = max_t / sqrt(number_traces_max_t);
8585

8686
printf("\033[A\033[2K");
87-
printf("meas: %7.2lf M, ", (number_traces_max_t / 1e6));
87+
printf("measure: %7.2lf M, ", (number_traces_max_t / 1e6));
8888
if (number_traces_max_t < ENOUGH_MEASURE) {
8989
printf("not enough measurements (%.0f still to go).\n",
9090
ENOUGH_MEASURE - number_traces_max_t);
@@ -170,8 +170,11 @@ static bool test_const(char *text, int mode)
170170
return result;
171171
}
172172

173-
#define DUT_FUNC_IMPL(op) \
174-
bool is_##op##_const(void) { return test_const(#op, DUT(op)); }
173+
#define DUT_FUNC_IMPL(op) \
174+
bool is_##op##_const(void) \
175+
{ \
176+
return test_const(#op, DUT(op)); \
177+
}
175178

176179
#define _(x) DUT_FUNC_IMPL(x)
177180
DUT_FUNCS

linenoise.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ static void refresh_multi_Line(struct line_state *l)
693693
/* Move cursor to right position. */
694694
rpos2 =
695695
(plen + l->pos + l->cols) / l->cols; /* current cursor relative row. */
696-
lndebug("rpos2 %d", rpos2);
696+
lndebug("right position %d", rpos2);
697697

698698
/* Go up till we reach the expected positon. */
699699
if (rows - rpos2 > 0) {

list.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,8 @@ static inline void list_move_tail(struct list_head *node,
457457
&entry->member != (head); entry = safe, \
458458
safe = list_entry(safe->member.next, typeof(*entry), member))
459459
#else
460-
#define list_for_each_entry_safe(entry, safe, head, member) \
461-
for (entry = (void *) 1; sizeof(struct { int i : -1; }); \
460+
#define list_for_each_entry_safe(entry, safe, head, member) \
461+
for (entry = safe = (void *) 1; sizeof(struct { int i : -1; }); \
462462
++(entry), ++(safe))
463463
#endif
464464

0 commit comments

Comments
 (0)