OpenSBI Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ivan Orlov <ivan.orlov0322@gmail.com>
To: opensbi@lists.infradead.org
Subject: [PATCH v2 0/5] SBIUnit: cover OpenSBI with tests
Date: Thu, 15 Feb 2024 16:16:20 +0000	[thread overview]
Message-ID: <20240215161625.314131-1-ivan.orlov0322@gmail.com> (raw)

It is good when the code is covered with tests. Tests help us to keep
the code clean and avoid regressions. Also, a good test is always a nice
documentation for the code it covers.

This patch series introduces SBIUnit - the set of macros and functions 
which simplify the unit test development for OpenSBI and automate tests
execution and evaluation.

This thing is mainly inspired by the KUnit framework from the Linux
Kernel, where the similar unit-test development tooling have been used
successfully for a pretty long time now. SBIUnit uses the same test
structure: multiple test cases are grouped together into the test
suites. SBIUnit also tries to reproduce the KUnit tests API while
allowing for some simplifications.

Another difference between the KUnit and SBIUnit is the location where
the tests are "stored". KUnit creates the ELF section in the kernel and
stores the pointers to all of the test suites there. SBIUnit takes
advantage of the 'carray' functionality of OpenSBI, keeping the pointers
to test suites in the auto-generated ".c" file. ELF section approach
could not be applied to SBIUnit, because OpenSBI could be used as a
static library when linking firmware. Use of a dedicated ELF section
would mean that all firmware linked with OpenSBI would need to have
this ELF section as well.

V1 -> V2:
- Add a cover letter
- Elaborate more on the differences between SBIUnit and KUnit
- Add a new patch adding a new entry to the 'clear' makefile target in
order to clear carray-generated files as well.
- (Patch-specific changes are described in the following patches)

Ivan Orlov (5):
  docs: Add documentation about tests and SBIUnit
  lib: Add SBIUnit testing macros and functions
  Makefile: clean '.c' files generated by carray
  lib: tests: Add a test for sbi_bitmap
  lib: tests: Add sbi_console test

 Makefile                      |   2 +
 docs/writing_tests.md         | 131 ++++++++++++++++++++++++++++++++++
 include/sbi/sbi_unit_test.h   |  74 +++++++++++++++++++
 lib/sbi/Kconfig               |   4 ++
 lib/sbi/objects.mk            |   6 ++
 lib/sbi/sbi_bitmap_test.c     | 103 ++++++++++++++++++++++++++
 lib/sbi/sbi_console.c         |   4 ++
 lib/sbi/sbi_console_test.c    | 102 ++++++++++++++++++++++++++
 lib/sbi/sbi_init.c            |   3 +
 lib/sbi/sbi_unit_test.c       |  43 +++++++++++
 lib/sbi/sbi_unit_tests.carray |   3 +
 11 files changed, 475 insertions(+)
 create mode 100644 docs/writing_tests.md
 create mode 100644 include/sbi/sbi_unit_test.h
 create mode 100644 lib/sbi/sbi_bitmap_test.c
 create mode 100644 lib/sbi/sbi_console_test.c
 create mode 100644 lib/sbi/sbi_unit_test.c
 create mode 100644 lib/sbi/sbi_unit_tests.carray

-- 
2.34.1



             reply	other threads:[~2024-02-15 16:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-15 16:16 Ivan Orlov [this message]
2024-02-15 16:16 ` [PATCH v2 1/5] docs: Add documentation about tests and SBIUnit Ivan Orlov
2024-02-28 13:47   ` Andrew Jones
2024-02-28 16:01     ` Ivan Orlov
2024-02-15 16:16 ` [PATCH v2 2/5] lib: Add SBIUnit testing macros and functions Ivan Orlov
2024-02-28 14:19   ` Andrew Jones
2024-02-28 16:12     ` Ivan Orlov
2024-02-28 16:30       ` Andrew Jones
2024-02-28 16:43         ` Ivan Orlov
2024-02-28 17:00           ` Andrew Jones
2024-02-28 17:10             ` Ivan Orlov
2024-02-15 16:16 ` [PATCH v2 3/5] Makefile: clean '.c' files generated by carray Ivan Orlov
2024-02-28 14:23   ` Andrew Jones
2024-02-28 16:18     ` Ivan Orlov
2024-02-28 16:32       ` Andrew Jones
2024-02-28 16:52         ` Ivan Orlov
2024-02-15 16:16 ` [PATCH v2 4/5] lib: tests: Add a test for sbi_bitmap Ivan Orlov
2024-02-28 14:28   ` Andrew Jones
2024-02-15 16:16 ` [PATCH v2 5/5] lib: tests: Add sbi_console test Ivan Orlov
2024-02-18  5:34   ` Xiang W
2024-02-18 20:54     ` Ivan Orlov
2024-02-28 14:33   ` Andrew Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240215161625.314131-1-ivan.orlov0322@gmail.com \
    --to=ivan.orlov0322@gmail.com \
    --cc=opensbi@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox