linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: sameeruddin shaik <sameeruddin.shaik8@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-trace-devel@vger.kernel.org, tz.stoyanov@gmail.com
Subject: Re: [PATCH] libtracefs: Unit test for the tracing filter API
Date: Wed, 7 Apr 2021 06:14:28 +0530	[thread overview]
Message-ID: <d8ef0d23-0765-51b2-be50-eba9282a879a@gmail.com> (raw)
In-Reply-To: <20210402105617.2bf3a438@gandalf.local.home>


On 02/04/21 8:26 pm, Steven Rostedt wrote:
> On Sat,  3 Apr 2021 07:31:00 +0530
> Sameeruddin shaik <sameeruddin.shaik8@gmail.com> wrote:
>
>> tracefs_function_filter();
> Need some more information in the change log. What is this testing?
>
>> Signed-off-by: Sameeruddin shaik <sameeruddin.shaik8@gmail.com>
>>
>> diff --git a/utest/tracefs-utest.c b/utest/tracefs-utest.c
>> index ed2693b..09e564f 100644
>> --- a/utest/tracefs-utest.c
>> +++ b/utest/tracefs-utest.c
>> @@ -11,6 +11,7 @@
>>   #include <time.h>
>>   #include <dirent.h>
>>   #include <ftw.h>
>> +#include <errno.h>
>>   
>>   #include <CUnit/CUnit.h>
>>   #include <CUnit/Basic.h>
>> @@ -1020,6 +1021,80 @@ static void test_custom_trace_dir(void)
>>   	free(dname);
>>   }
>>   
>> +static int test_instance_filter(struct tracefs_instance *instance,
>> +				const char **filters, const char *module,
>> +				int flags)
>> +{
>> +	int ret;
>> +	int i;
>> +
>> +	if (filters) {
>> +		for (i = 0; filters[i]; i++) {
>> +			ret = tracefs_function_filter(instance, filters[i],
>> +						      module, flags);
>> +			if (ret) {
>> +				if (errno == EINVAL)
>> +					printf("Filter %s did not match\n",
>> +					       filters[i]);
>> +				else
>> +					printf("Failed writing %s\n",
>> +					       filters[i]);
>> +			}
>> +		}
>> +	} else {
>> +		ret = tracefs_function_filter(instance, NULL, module, flags);
>> +	}
>> +	return ret;
>> +}
>> +
>> +static void test_tracefs_function_filter(void)
>> +{
>> +	const char *filter[] = {"run_init_process", "ufs*", "^ext4.*$", NULL};
> I ran this and it failed, because my box has no functions that start with
> "ufs" nor "ext4" (I use an xfs file system).
>
> You need to use core function names like "sched*" or "irq*", because ufs
> and ext4 are modules that do not exist in all machines that this may be
> executed on.
>
>> +	const char *future_filter[] = {"write_dummy", "read_dummy", NULL};
>> +	const char *future_module = "dummy";
>> +	struct tracefs_instance *instance;
>> +	const char *module = "btrtl";
> I also do not have the btrtl module. You may need to see what modules are
> loaded (reading /proc/modules will help you there).
>
>> +	int ret;
>> +
>> +	instance = tracefs_instance_create(TEST_INSTANCE_NAME);
>> +	CU_TEST(instance != NULL);
>> +
>> +	ret = tracefs_function_filter(instance, NULL, NULL,
>> +				      TRACEFS_FL_RESET | TRACEFS_FL_CONTINUE);
>> +	if (ret) {
>> +		printf("Failed to reset the filter\n");
> Should the above be a CU_TEST failure?
> +		if (ret < 0)
> +			tracefs_function_filter(instance, NULL, NULL, 0);
> +	}
> +	/* Test string, kernel glob and regex for specific_instance*/
> +	ret = test_instance_filter(instance, filter, NULL, TRACEFS_FL_CONTINUE);
> +	CU_ASSERT(ret == 0);
> +	/* Test Module only with no filters*/
> +	ret = test_instance_filter(instance, NULL, module, TRACEFS_FL_CONTINUE);
> +	CU_ASSERT(ret == 0);
> +	ret = test_instance_filter(instance, future_filter, future_module,
> +				   TRACEFS_FL_CONTINUE | TRACEFS_FL_FUTURE);
> +	CU_ASSERT(ret == 0);
> +	tracefs_function_filter(instance, NULL, NULL, 0);
> Should the above result also be tested?

Is it really needs to be tested?, because anyhow if we have any error, 
it will be thrown at the above lines

But anyhow, i will test the result here, since we are commiting the 
changes in the file.

>> +
>> +	ret = tracefs_function_filter(NULL, NULL, NULL,
>> +				      TRACEFS_FL_RESET | TRACEFS_FL_CONTINUE);
>> +	if (ret) {
> And here too.
okay.
>> +		printf("Failed to reset the filter\n");
>> +		if (ret < 0)
>> +			tracefs_function_filter(instance, NULL, NULL, 0);
>> +	}
>> +	/* Test top instance*/
>> +	ret = test_instance_filter(NULL, filter, NULL, TRACEFS_FL_CONTINUE);
>> +	CU_ASSERT(ret == 0);
>> +	ret = test_instance_filter(NULL, NULL, module, TRACEFS_FL_CONTINUE);
> As I stated above, I don't have the module you picked, and will most
> definitely fail this test as FUTURE is not set.

Yeah will try to add some standard modules.

Thanks,

sameer.



      reply	other threads:[~2021-04-06  0:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-03  2:01 [PATCH] libtracefs: Unit test for the tracing filter API Sameeruddin shaik
2021-04-02 14:56 ` Steven Rostedt
2021-04-07  0:44   ` sameeruddin shaik [this message]

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=d8ef0d23-0765-51b2-be50-eba9282a879a@gmail.com \
    --to=sameeruddin.shaik8@gmail.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tz.stoyanov@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).