Skip to content

Commit 250e138

Browse files
jones-drewsean-jc
authored andcommitted
KVM: selftests: Remove redundant newlines
TEST_* functions append their own newline. Remove newlines from TEST_* callsites to avoid extra newlines in output. Signed-off-by: Andrew Jones <ajones@ventanamicro.com> Link: https://lore.kernel.org/r/20231206170241.82801-8-ajones@ventanamicro.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 02add85 commit 250e138

17 files changed

+38
-38
lines changed

tools/testing/selftests/kvm/demand_paging_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ static void vcpu_worker(struct memstress_vcpu_args *vcpu_args)
4545

4646
/* Let the guest access its memory */
4747
ret = _vcpu_run(vcpu);
48-
TEST_ASSERT(ret == 0, "vcpu_run failed: %d\n", ret);
48+
TEST_ASSERT(ret == 0, "vcpu_run failed: %d", ret);
4949
if (get_ucall(vcpu, NULL) != UCALL_SYNC) {
5050
TEST_ASSERT(false,
51-
"Invalid guest sync status: exit_reason=%s\n",
51+
"Invalid guest sync status: exit_reason=%s",
5252
exit_reason_str(run->exit_reason));
5353
}
5454

tools/testing/selftests/kvm/dirty_log_perf_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ static void vcpu_worker(struct memstress_vcpu_args *vcpu_args)
8888
ret = _vcpu_run(vcpu);
8989
ts_diff = timespec_elapsed(start);
9090

91-
TEST_ASSERT(ret == 0, "vcpu_run failed: %d\n", ret);
91+
TEST_ASSERT(ret == 0, "vcpu_run failed: %d", ret);
9292
TEST_ASSERT(get_ucall(vcpu, NULL) == UCALL_SYNC,
93-
"Invalid guest sync status: exit_reason=%s\n",
93+
"Invalid guest sync status: exit_reason=%s",
9494
exit_reason_str(run->exit_reason));
9595

9696
pr_debug("Got sync event from vCPU %d\n", vcpu_idx);

tools/testing/selftests/kvm/dirty_log_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ static void default_after_vcpu_run(struct kvm_vcpu *vcpu, int ret, int err)
262262
"vcpu run failed: errno=%d", err);
263263

264264
TEST_ASSERT(get_ucall(vcpu, NULL) == UCALL_SYNC,
265-
"Invalid guest sync status: exit_reason=%s\n",
265+
"Invalid guest sync status: exit_reason=%s",
266266
exit_reason_str(run->exit_reason));
267267

268268
vcpu_handle_sync_stop();
@@ -410,7 +410,7 @@ static void dirty_ring_after_vcpu_run(struct kvm_vcpu *vcpu, int ret, int err)
410410
pr_info("vcpu continues now.\n");
411411
} else {
412412
TEST_ASSERT(false, "Invalid guest sync status: "
413-
"exit_reason=%s\n",
413+
"exit_reason=%s",
414414
exit_reason_str(run->exit_reason));
415415
}
416416
}

tools/testing/selftests/kvm/get-reg-list.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static void check_supported(struct vcpu_reg_list *c)
152152
continue;
153153

154154
__TEST_REQUIRE(kvm_has_cap(s->capability),
155-
"%s: %s not available, skipping tests\n",
155+
"%s: %s not available, skipping tests",
156156
config_name(c), s->name);
157157
}
158158
}

tools/testing/selftests/kvm/guest_print_test.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static void ucall_abort(const char *assert_msg, const char *expected_assert_msg)
9898
int offset = len_str - len_substr;
9999

100100
TEST_ASSERT(len_substr <= len_str,
101-
"Expected '%s' to be a substring of '%s'\n",
101+
"Expected '%s' to be a substring of '%s'",
102102
assert_msg, expected_assert_msg);
103103

104104
TEST_ASSERT(strcmp(&assert_msg[offset], expected_assert_msg) == 0,
@@ -116,7 +116,7 @@ static void run_test(struct kvm_vcpu *vcpu, const char *expected_printf,
116116
vcpu_run(vcpu);
117117

118118
TEST_ASSERT(run->exit_reason == UCALL_EXIT_REASON,
119-
"Unexpected exit reason: %u (%s),\n",
119+
"Unexpected exit reason: %u (%s),",
120120
run->exit_reason, exit_reason_str(run->exit_reason));
121121

122122
switch (get_ucall(vcpu, &uc)) {
@@ -161,11 +161,11 @@ static void test_limits(void)
161161
vcpu_run(vcpu);
162162

163163
TEST_ASSERT(run->exit_reason == UCALL_EXIT_REASON,
164-
"Unexpected exit reason: %u (%s),\n",
164+
"Unexpected exit reason: %u (%s),",
165165
run->exit_reason, exit_reason_str(run->exit_reason));
166166

167167
TEST_ASSERT(get_ucall(vcpu, &uc) == UCALL_ABORT,
168-
"Unexpected ucall command: %lu, Expected: %u (UCALL_ABORT)\n",
168+
"Unexpected ucall command: %lu, Expected: %u (UCALL_ABORT)",
169169
uc.cmd, UCALL_ABORT);
170170

171171
kvm_vm_free(vm);

tools/testing/selftests/kvm/hardware_disable_test.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static void *run_vcpu(void *arg)
4141

4242
vcpu_run(vcpu);
4343

44-
TEST_ASSERT(false, "%s: exited with reason %d: %s\n",
44+
TEST_ASSERT(false, "%s: exited with reason %d: %s",
4545
__func__, run->exit_reason,
4646
exit_reason_str(run->exit_reason));
4747
pthread_exit(NULL);
@@ -55,7 +55,7 @@ static void *sleeping_thread(void *arg)
5555
fd = open("/dev/null", O_RDWR);
5656
close(fd);
5757
}
58-
TEST_ASSERT(false, "%s: exited\n", __func__);
58+
TEST_ASSERT(false, "%s: exited", __func__);
5959
pthread_exit(NULL);
6060
}
6161

@@ -118,7 +118,7 @@ static void run_test(uint32_t run)
118118
for (i = 0; i < VCPU_NUM; ++i)
119119
check_join(threads[i], &b);
120120
/* Should not be reached */
121-
TEST_ASSERT(false, "%s: [%d] child escaped the ninja\n", __func__, run);
121+
TEST_ASSERT(false, "%s: [%d] child escaped the ninja", __func__, run);
122122
}
123123

124124
void wait_for_child_setup(pid_t pid)

tools/testing/selftests/kvm/kvm_create_max_vcpus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ int main(int argc, char *argv[])
6565

6666
int r = setrlimit(RLIMIT_NOFILE, &rl);
6767
__TEST_REQUIRE(r >= 0,
68-
"RLIMIT_NOFILE hard limit is too low (%d, wanted %d)\n",
68+
"RLIMIT_NOFILE hard limit is too low (%d, wanted %d)",
6969
old_rlim_max, nr_fds_wanted);
7070
} else {
7171
TEST_ASSERT(!setrlimit(RLIMIT_NOFILE, &rl), "setrlimit() failed!");

tools/testing/selftests/kvm/kvm_page_table_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ static void *vcpu_worker(void *data)
204204
ret = _vcpu_run(vcpu);
205205
ts_diff = timespec_elapsed(start);
206206

207-
TEST_ASSERT(ret == 0, "vcpu_run failed: %d\n", ret);
207+
TEST_ASSERT(ret == 0, "vcpu_run failed: %d", ret);
208208
TEST_ASSERT(get_ucall(vcpu, NULL) == UCALL_SYNC,
209-
"Invalid guest sync status: exit_reason=%s\n",
209+
"Invalid guest sync status: exit_reason=%s",
210210
exit_reason_str(vcpu->run->exit_reason));
211211

212212
pr_debug("Got sync event from vCPU %d\n", vcpu->id);

tools/testing/selftests/kvm/lib/elf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ void kvm_vm_elf_load(struct kvm_vm *vm, const char *filename)
184184
"Seek to program segment offset failed,\n"
185185
" program header idx: %u errno: %i\n"
186186
" offset_rv: 0x%jx\n"
187-
" expected: 0x%jx\n",
187+
" expected: 0x%jx",
188188
n1, errno, (intmax_t) offset_rv,
189189
(intmax_t) phdr.p_offset);
190190
test_read(fd, addr_gva2hva(vm, phdr.p_vaddr),

tools/testing/selftests/kvm/lib/kvm_util.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ static uint64_t vm_nr_pages_required(enum vm_guest_mode mode,
320320
uint64_t nr_pages;
321321

322322
TEST_ASSERT(nr_runnable_vcpus,
323-
"Use vm_create_barebones() for VMs that _never_ have vCPUs\n");
323+
"Use vm_create_barebones() for VMs that _never_ have vCPUs");
324324

325325
TEST_ASSERT(nr_runnable_vcpus <= kvm_check_cap(KVM_CAP_MAX_VCPUS),
326326
"nr_vcpus = %d too large for host, max-vcpus = %d",
@@ -491,15 +491,15 @@ void kvm_pin_this_task_to_pcpu(uint32_t pcpu)
491491
CPU_ZERO(&mask);
492492
CPU_SET(pcpu, &mask);
493493
r = sched_setaffinity(0, sizeof(mask), &mask);
494-
TEST_ASSERT(!r, "sched_setaffinity() failed for pCPU '%u'.\n", pcpu);
494+
TEST_ASSERT(!r, "sched_setaffinity() failed for pCPU '%u'.", pcpu);
495495
}
496496

497497
static uint32_t parse_pcpu(const char *cpu_str, const cpu_set_t *allowed_mask)
498498
{
499499
uint32_t pcpu = atoi_non_negative("CPU number", cpu_str);
500500

501501
TEST_ASSERT(CPU_ISSET(pcpu, allowed_mask),
502-
"Not allowed to run on pCPU '%d', check cgroups?\n", pcpu);
502+
"Not allowed to run on pCPU '%d', check cgroups?", pcpu);
503503
return pcpu;
504504
}
505505

@@ -529,7 +529,7 @@ void kvm_parse_vcpu_pinning(const char *pcpus_string, uint32_t vcpu_to_pcpu[],
529529
int i, r;
530530

531531
cpu_list = strdup(pcpus_string);
532-
TEST_ASSERT(cpu_list, "strdup() allocation failed.\n");
532+
TEST_ASSERT(cpu_list, "strdup() allocation failed.");
533533

534534
r = sched_getaffinity(0, sizeof(allowed_mask), &allowed_mask);
535535
TEST_ASSERT(!r, "sched_getaffinity() failed");
@@ -538,7 +538,7 @@ void kvm_parse_vcpu_pinning(const char *pcpus_string, uint32_t vcpu_to_pcpu[],
538538

539539
/* 1. Get all pcpus for vcpus. */
540540
for (i = 0; i < nr_vcpus; i++) {
541-
TEST_ASSERT(cpu, "pCPU not provided for vCPU '%d'\n", i);
541+
TEST_ASSERT(cpu, "pCPU not provided for vCPU '%d'", i);
542542
vcpu_to_pcpu[i] = parse_pcpu(cpu, &allowed_mask);
543543
cpu = strtok(NULL, delim);
544544
}
@@ -1057,7 +1057,7 @@ void vm_mem_add(struct kvm_vm *vm, enum vm_mem_backing_src_type src_type,
10571057
TEST_ASSERT(ret == 0, "KVM_SET_USER_MEMORY_REGION2 IOCTL failed,\n"
10581058
" rc: %i errno: %i\n"
10591059
" slot: %u flags: 0x%x\n"
1060-
" guest_phys_addr: 0x%lx size: 0x%lx guest_memfd: %d\n",
1060+
" guest_phys_addr: 0x%lx size: 0x%lx guest_memfd: %d",
10611061
ret, errno, slot, flags,
10621062
guest_paddr, (uint64_t) region->region.memory_size,
10631063
region->region.guest_memfd);
@@ -1222,7 +1222,7 @@ void vm_guest_mem_fallocate(struct kvm_vm *vm, uint64_t base, uint64_t size,
12221222
len = min_t(uint64_t, end - gpa, region->region.memory_size - offset);
12231223

12241224
ret = fallocate(region->region.guest_memfd, mode, fd_offset, len);
1225-
TEST_ASSERT(!ret, "fallocate() failed to %s at %lx (len = %lu), fd = %d, mode = %x, offset = %lx\n",
1225+
TEST_ASSERT(!ret, "fallocate() failed to %s at %lx (len = %lu), fd = %d, mode = %x, offset = %lx",
12261226
punch_hole ? "punch hole" : "allocate", gpa, len,
12271227
region->region.guest_memfd, mode, fd_offset);
12281228
}
@@ -1265,7 +1265,7 @@ struct kvm_vcpu *__vm_vcpu_add(struct kvm_vm *vm, uint32_t vcpu_id)
12651265
struct kvm_vcpu *vcpu;
12661266

12671267
/* Confirm a vcpu with the specified id doesn't already exist. */
1268-
TEST_ASSERT(!vcpu_exists(vm, vcpu_id), "vCPU%d already exists\n", vcpu_id);
1268+
TEST_ASSERT(!vcpu_exists(vm, vcpu_id), "vCPU%d already exists", vcpu_id);
12691269

12701270
/* Allocate and initialize new vcpu structure. */
12711271
vcpu = calloc(1, sizeof(*vcpu));

0 commit comments

Comments
 (0)