All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 0/8] Sparse based checker and rule proposal
Date: Wed, 28 Jul 2021 13:34:04 +0100	[thread overview]
Message-ID: <20210728123412.31858-1-rpalethorpe@suse.com> (raw)

Hello,

So it turns out that it is quite easy to implement the TST_RET/ERR
check in Sparse. It compiles the code into an IR which is just the
right abstraction for the test. It is also possible to inspect the AST
with Sparse. It appears more difficult to inspect the AST before
macros are expanded.

Sparse is not packaged as a shared library, but has few/no
dependencies and is easy to compile. It seems like it was meant to be
vendored. Including it as a git module seems reasonable to me. Please
see tools/sparse/README.md.

There are still a lot of errors/noise when running 'make check' on the
entire tree. These are mainly caused by old function definitions and
such. They need to be fixed before the tool can be used properly.

Also I have tried to document the rule and created a list of rules. So
this can also be taken as a formal proposal for the rule itself.

Thanks,

V3:
* Rename main to sparse-ltp
* Unify TEST/TST_EXP docs
* Add/fix a couple of links in the docs
* minor formatting changes in sparse-ltp
* Add note on building with -m32

V2:
* Automatically download and build sparse.
* Only build sparse if "make check" is run. It is filtered from "make all".
* Move libtsc.h out of the realtime tests dir. Note that checking of metldown.c
  now fails because it uses a GCC builtin sparse does not recognize.

As mentioned above, there are various errors during checking that need
fixing. For the most part these are legit errors (usually old style
function definitions or redefining of symbols). With stuff like
metldown I am tempted to filter it, but OTOH it looks relatively
straight forward to add a builtin to Sparse upstream. I just need time
to do it. First though I would like to get "make check" working on the
library, so we can put that in CI.

Richard Palethorpe (8):
  Add Sparse based checker and TST_RET/ERR check
  Add 'make check' to the build system
  doc: Add rules and recommendations list
  doc: Remind authors and maintainers to run make check
  doc: Document TEST macro and state TST_RET/ERR rule LTP-002
  Reference LTP-002 rule in Cocci scripts
  API: Move libtsc.h from realtime tests include to tst_tsc.h
  API/tst_tsc: Add guards and remove some boilerplate

 .gitmodules                                   |   3 +
 Makefile                                      |   8 +
 doc/c-test-api.txt                            |  54 ++++++-
 doc/library-api-writing-guidelines.txt        |  14 ++
 doc/maintainer-patch-review-checklist.txt     |   4 +-
 doc/rules.tsv                                 |   3 +
 doc/test-writing-guidelines.txt               |   8 +
 include/mk/env_post.mk                        |   8 +
 include/mk/generic_leaf_target.inc            |   5 +-
 include/mk/generic_trunk_target.inc           |   7 +-
 include/mk/lib.mk                             |   3 +
 include/mk/module.mk                          |   2 +
 include/mk/rules.mk                           |   9 ++
 include/mk/sparse.mk                          |   9 ++
 include/mk/testcases.mk                       |   1 +
 .../include/libtsc.h => include/tst_tsc.h     |  35 +----
 .../coccinelle/libltp-test-macro-vars.cocci   |   6 +-
 scripts/coccinelle/libltp-test-macro.cocci    |   4 +-
 testcases/cve/Makefile                        |   2 -
 testcases/cve/meltdown.c                      |   2 +-
 testcases/open_posix_testsuite/Makefile       |   4 +
 .../func/async_handler/async_handler_tsc.c    |   3 +-
 .../func/measurement/preempt_timing.c         |   3 +-
 .../realtime/func/measurement/rdtsc-latency.c |   3 +-
 tools/Makefile                                |   2 +
 tools/sparse/.gitignore                       |   1 +
 tools/sparse/Makefile                         |  27 ++++
 tools/sparse/README.md                        |  51 ++++++
 tools/sparse/sparse-ltp.c                     | 147 ++++++++++++++++++
 tools/sparse/sparse-src                       |   1 +
 30 files changed, 382 insertions(+), 47 deletions(-)
 create mode 100644 doc/rules.tsv
 create mode 100644 include/mk/sparse.mk
 rename testcases/realtime/include/libtsc.h => include/tst_tsc.h (53%)
 create mode 100644 tools/sparse/.gitignore
 create mode 100644 tools/sparse/Makefile
 create mode 100644 tools/sparse/README.md
 create mode 100644 tools/sparse/sparse-ltp.c
 create mode 160000 tools/sparse/sparse-src

-- 
2.31.1


             reply	other threads:[~2021-07-28 12:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-28 12:34 Richard Palethorpe [this message]
2021-07-28 12:34 ` [LTP] [PATCH v3 1/8] Add Sparse based checker and TST_RET/ERR check Richard Palethorpe
2021-07-28 12:34 ` [LTP] [PATCH v3 2/8] Add 'make check' to the build system Richard Palethorpe
2021-08-27 12:06   ` Petr Vorel
2021-08-30 14:33     ` Cyril Hrubis
2021-08-30 18:13       ` Petr Vorel
2021-07-28 12:34 ` [LTP] [PATCH v3 3/8] doc: Add rules and recommendations list Richard Palethorpe
2021-07-28 12:34 ` [LTP] [PATCH v3 4/8] doc: Remind authors and maintainers to run make check Richard Palethorpe
2021-07-28 12:34 ` [LTP] [PATCH v3 5/8] doc: Document TEST macro and state TST_RET/ERR rule LTP-002 Richard Palethorpe
2021-07-29 15:27   ` Cyril Hrubis
2021-07-28 12:34 ` [LTP] [PATCH v3 6/8] Reference LTP-002 rule in Cocci scripts Richard Palethorpe
2021-07-28 12:34 ` [LTP] [PATCH v3 7/8] API: Move libtsc.h from realtime tests include to tst_tsc.h Richard Palethorpe
2021-07-28 12:34 ` [LTP] [PATCH v3 8/8] API/tst_tsc: Add guards and remove some boilerplate Richard Palethorpe
2021-08-09 20:12 ` [LTP] Review of C static analyses tools Richard Palethorpe

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=20210728123412.31858-1-rpalethorpe@suse.com \
    --to=rpalethorpe@suse.com \
    --cc=ltp@lists.linux.it \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.