From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] lib: Add library function for parsing kernel config
Date: Fri, 16 Nov 2018 14:53:15 +0100 [thread overview]
Message-ID: <20181116135315.GD29013@rei.lan> (raw)
In-Reply-To: <4a063677-8a43-2737-b9af-3459a57fa3f5@arm.com>
Hi!
> this morning I was just thinking about brutally zcatting config.gz to be
> able to skip some tests based upon current Kernel configs (not
> drivers/moduleoptions)...and I'd need a mechanism to do that...then I
> saw this patch :D
That's the beauty of opensource, your problems gets solved even before
you try :-).
...
> +#define TST_NO_DEFAULT_MAIN
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <tst_test.h>
> +#include <tst_kconfig.h>
> +
> +int main(int argc, const char **argv)
> +{
> + int missing = 0;
> + const char **cfg = NULL;
> +
> + if (argc < 2)
> + return -1;
> +
> + for (cfg = &argv[1]; !missing && *cfg; cfg++) {
> + char rval = '\0';
> +
> + fprintf(stderr, "Check for: %s\n", *cfg);
> + rval = tst_kconfig(*cfg);
> + switch (rval) {
> + case 'y':
> + case 'm':
> + tst_res(TINFO, "Kernel %s found", *cfg);
> + break;
> + default:
> + missing = 1;
> + tst_res(TINFO, "Kernel is missing %s", *cfg);
> + break;
> + }
> + }
> +
> + return missing;
> +}
>
> and it seems to work !
Hmm, I guess that we can even pass argv+1 to the tst_kconfig_check(),
the function will exit with 32 on missing modules and with 2 if
something went wrong.
We can slightly modify it, if we want to have better control over the
exit functions here, but generally that should be even easier than this.
> cmdline="quota_remount_test01.sh"
> contacts=""
> analysis=exit
> <<<test_output>>>
> incrementing stop
> Check for: CONFIG_QFMT_V1
> tst_check_kconfigs.c:44: INFO: Kernel is missing CONFIG_QFMT_V1
> quota_remount_test01 1 TCONF : ltpapicmd.c:188: Kernel QUOTA
> Options NOT configured!
> <<<execution_status>>>
> initiation_status="ok"
> duration=0 termination_type=exited termination_id=32 corefile=no
> cutime=0 cstime=0
>
> Do you think could be useful ?
Yes, we will likely need shell helper for this API.
> Or should be done another way really (I'm brand new to LTP tests...) ?
Actually for the case quotas calling quotactl(2) and checking for ENOSYS
may be easier and probably prefered.
We may want to record the required config options somewhere though.
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2018-11-16 13:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-15 13:44 [LTP] [PATCH] lib: Add library function for parsing kernel config Cyril Hrubis
2018-11-15 18:57 ` Cristian Marussi
2018-11-16 13:53 ` Cyril Hrubis [this message]
2018-11-15 20:16 ` Tim.Bird
2018-11-16 13:59 ` Cyril Hrubis
2018-11-21 19:53 ` Tim.Bird
2018-11-15 20:43 ` Tim.Bird
2018-11-16 13:57 ` Cyril Hrubis
2018-11-16 3:54 ` Pengfei Xu
2018-11-16 4:03 ` Tim.Bird
2018-11-16 4:57 ` Pengfei Xu
2018-11-16 14:00 ` Cyril Hrubis
2018-11-17 5:41 ` Pengfei Xu
2018-11-23 4:56 ` Sandeep Patil
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=20181116135315.GD29013@rei.lan \
--to=chrubis@suse.cz \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox