public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: "xuyang2018.jy@fujitsu.com" <xuyang2018.jy@fujitsu.com>
To: Petr Vorel <pvorel@suse.cz>
Cc: "ltp@lists.linux.it" <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH v4 3/4] zram/zram03: Convert into new api
Date: Fri, 17 Dec 2021 09:42:23 +0000	[thread overview]
Message-ID: <61BC5B84.6010701@fujitsu.com> (raw)
In-Reply-To: <YbxI10d517WiDMHW@pevik>

Hi Petr
> Hi Xu,
>
>> Also add hot_add/hot_remove in setup/cleanup, so this case can adapt the situation that
>> zram module is being used by zram-generator or zram module is builtin.
> Very nice. Again, I like you added both CONFIG_ZRAM=y support and simultaneous
> run.
>
> Reviewed-by: Petr Vorel<pvorel@suse.cz>
>
>> diff --git a/testcases/kernel/device-drivers/zram/zram03.c b/testcases/kernel/device-drivers/zram/zram03.c
> ...
>> - * You should have received a copy of the GNU General Public License
>> - * along with this program; if not, write the Free Software
>> - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
>> - * 02110-1301, USA.
>> + * This case check whether data read from zram device is consistent with
>> + * thoese are written.
>>    */
>
>> +
> nit: I'd remove this extra line
OK
>>   #include<sys/types.h>
>>   #include<sys/stat.h>
>
> ...
>>   	if (i != SIZE - 1) {
>> -		tst_resm(TFAIL, "expect size: %ld, actual size: %ld.",
>> +		tst_res(TFAIL, "expect size: %ld, actual size: %ld.",
>>   			 SIZE - 1, i);
>>   	} else if (s[i] != '\0') {
>> -		tst_resm(TFAIL, "zram device seems not null terminated");
>> +		tst_res(TFAIL, "zram device seems not null terminated");
>>   	} else if (fail) {
>> -		tst_resm(TFAIL, "%ld failed bytes found.", fail);
>> +		tst_res(TFAIL, "%ld failed bytes found", fail);
>>   	} else {
>> -		tst_resm(TPASS, "data read from zram device is consistent "
>> +		tst_res(TPASS, "data read from zram device is consistent "
>>   			 "with those are written");
> nit: I'd join this line (less than over 100)
ok
>>   	}
>
> ...
>> +static void setup(void)
>> +{
>> +	const char *const cmd_modprobe[] = {"modprobe", "zram", NULL};
>> +	int hot_add_fd;
>> +
>> +	if (!access(ZRAM_CONTROL_PATH, F_OK)) {
>> +		hot_add_fd = SAFE_OPEN(HOT_ADD_PATH, O_RDONLY);
>> +		SAFE_READ(0, hot_add_fd,&buf, 20);
>> +		dev_num = atoi(buf);
>> +		SAFE_CLOSE(hot_add_fd);
>> +		hot_add_flag = 1;
> We have SAFE_FILE_SCANF(), you can use just:
> 		SAFE_FILE_SCANF(HOT_ADD_PATH, "%d",&dev_num);
Oh, yes, I forgot it...
>
>> +	} else {
>> +		SAFE_CMD(cmd_modprobe, NULL, NULL);
>> +		modprobe = 1;
>> +	}
>> +	sprintf(zram_block_path, "/sys/block/zram%d", dev_num);
>> +	sprintf(zram_dev_path, "/dev/zram%d", dev_num);
>> +}
>> +
>> +static void cleanup(void)
>> +{
>> +	const char *const cmd_rmmod[] = {"rmmod", "zram", NULL};
>> +	int hot_remove_fd;
>> +
>> +	if (hot_add_flag) {
>> +		hot_remove_fd = SAFE_OPEN(HOT_REMOVE_PATH, O_WRONLY);
>> +		SAFE_WRITE(0, hot_remove_fd, buf, 20);
>> +		SAFE_CLOSE(hot_remove_fd);
>> +	}
> Ad here
> 	if (hot_add_flag)
> 		SAFE_FILE_PRINTF(HOT_REMOVE_PATH, "%d", dev_num);
>
> Kind regards,
> Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2021-12-17  9:42 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-15  7:20 [LTP] [PATCH v4 1/4] swapping01: skip test if zram-swap is being used Yang Xu
2021-12-15  7:20 ` [LTP] [PATCH v4 2/4] zram/zram_lib.sh: adapt the situation that zram device " Yang Xu
2021-12-17  7:48   ` Petr Vorel
2021-12-17  9:34     ` xuyang2018.jy
2021-12-17 10:34       ` Petr Vorel
2021-12-20  2:58         ` xuyang2018.jy
2021-12-20  8:52           ` Petr Vorel
2021-12-17  7:49   ` Petr Vorel
2021-12-15  7:20 ` [LTP] [PATCH v4 3/4] zram/zram03: Convert into new api Yang Xu
2021-12-17  8:22   ` Petr Vorel
2021-12-17  9:42     ` xuyang2018.jy [this message]
2021-12-17  8:24   ` Petr Vorel
2021-12-15  7:20 ` [LTP] [PATCH v4 4/4] zram/zram01.sh: Use mem_used_total field instead of compr_data_size field Yang Xu
2021-12-17  8:47   ` Petr Vorel
2021-12-17  9:45     ` xuyang2018.jy
2021-12-17 10:36       ` Petr Vorel
2021-12-17  7:01 ` [LTP] [PATCH v4 1/4] swapping01: skip test if zram-swap is being used Petr Vorel
2021-12-17  7:04   ` xuyang2018.jy

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=61BC5B84.6010701@fujitsu.com \
    --to=xuyang2018.jy@fujitsu.com \
    --cc=ltp@lists.linux.it \
    --cc=pvorel@suse.cz \
    /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