Blame view

test/ut.c 793 Bytes
83d290c56   Tom Rini   SPDX: Convert all...
1
  // SPDX-License-Identifier: GPL-2.0+
2e7d35d2a   Simon Glass   dm: Add basic tests
2
  /*
e721b882e   Joe Hershberger   test: Generalize ...
3
   * Simple unit test library
2e7d35d2a   Simon Glass   dm: Add basic tests
4
5
   *
   * Copyright (c) 2013 Google, Inc
2e7d35d2a   Simon Glass   dm: Add basic tests
6
7
8
   */
  
  #include <common.h>
e721b882e   Joe Hershberger   test: Generalize ...
9
10
  #include <test/test.h>
  #include <test/ut.h>
2e7d35d2a   Simon Glass   dm: Add basic tests
11

9ce8b4020   Simon Glass   test: Record and ...
12
  DECLARE_GLOBAL_DATA_PTR;
e721b882e   Joe Hershberger   test: Generalize ...
13
  void ut_fail(struct unit_test_state *uts, const char *fname, int line,
2e7d35d2a   Simon Glass   dm: Add basic tests
14
15
  	     const char *func, const char *cond)
  {
9ce8b4020   Simon Glass   test: Record and ...
16
  	gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD);
2e7d35d2a   Simon Glass   dm: Add basic tests
17
18
  	printf("%s:%d, %s(): %s
  ", fname, line, func, cond);
e721b882e   Joe Hershberger   test: Generalize ...
19
  	uts->fail_count++;
2e7d35d2a   Simon Glass   dm: Add basic tests
20
  }
e721b882e   Joe Hershberger   test: Generalize ...
21
  void ut_failf(struct unit_test_state *uts, const char *fname, int line,
2e7d35d2a   Simon Glass   dm: Add basic tests
22
23
24
  	      const char *func, const char *cond, const char *fmt, ...)
  {
  	va_list args;
9ce8b4020   Simon Glass   test: Record and ...
25
  	gd->flags &= ~(GD_FLG_SILENT | GD_FLG_RECORD);
2e7d35d2a   Simon Glass   dm: Add basic tests
26
27
28
29
30
31
  	printf("%s:%d, %s(): %s: ", fname, line, func, cond);
  	va_start(args, fmt);
  	vprintf(fmt, args);
  	va_end(args);
  	putc('
  ');
e721b882e   Joe Hershberger   test: Generalize ...
32
  	uts->fail_count++;
2e7d35d2a   Simon Glass   dm: Add basic tests
33
  }