Add needs_devices && basic uart test
cover Add needs_devices && basic uart test
This is not yet finished and work-in-progress, but it shows the directions I think the device drivers should take.
This series adds a .needs_devices array of strings to the tst_test structure which is expected to hold well defined list of environment variables with well known names. In this case its UART_RX and UART_TX which should be obvious. Other tests may need I2C_ADDR etc.
The value of these depends on a particular hardware/lab settings so apart from checking that these are defined the test libary does not attempt to do anything about these. The expectation here is that in the future the test description format I'm working on would be parsed by the test execution framework, which would then call a user defined helper script to get the values for these variables. For now we would have to run these scripts prior the LTP run to get these variables defined.
Cyril Hrubis (2):
tst_test: Add support for needs_devices
device_drivers/uart01: Add uart01 test
include/tst_test.h | 3 + lib/tst_test.c | 32 ++ runtest/kernel_misc | 5 + .../kernel/device-drivers/uart/.gitignore | 1 + testcases/kernel/device-drivers/uart/Makefile | 4 + testcases/kernel/device-drivers/uart/uart01.c | 522 ++++++++++++++++++ 6 files changed, 567 insertions(+) create mode 100644 testcases/kernel/device-drivers/uart/.gitignore create mode 100644 testcases/kernel/device-drivers/uart/Makefile create mode 100644 testcases/kernel/device-drivers/uart/uart01.c
Signature · 1 line
2.24.1
PATCH 1/2 tst_test: Add support for needs_devices
Which is a list of environment variables needed for a test.
--- include/tst_test.h | 3 +++ lib/tst_test.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+)
include/tst_test.h +3 -0
@@ -213,6 +213,9 @@ struct tst_test {/* NULL terminated array of needed kernel drivers */ const char *const *needs_drivers; +/* NULL terminated array of devices */ +const char *const *needs_devices; +/* * NULL terminated array of (/proc, /sys) files to save * before setup and restore after cleanup
lib/tst_test.c +32 -0
@@ -464,6 +464,22 @@ static void print_test_tags(void)printf ("\n" ); } +static void print_test_devices (void ) +{ +const char *const *devices = tst_test->needs_devices; +int i; + +if (!devices) +return ; + +printf ("\nNeeded devices\n--------------\n" ); + +for (i =0 ; devices[i]; i++) +printf ("%s\n" , devices[i]); + +printf ("\n" ); +} +static void check_option_collision (void ) {unsigned int i, j;
@@ -543,6 +559,7 @@ static void parse_opts(int argc, char *argv[])case 'h' :print_help ();print_test_tags (); +print_test_devices ();exit (0 );case 'i' : iterations =atoi (optarg);
@@ -890,6 +907,21 @@ static void do_setup(int argc, char *argv[])tst_brk (TCONF ,"%s driver not available" , name); } +if (tst_test->needs_devices) { +int i; +const char *name; +int exit =0 ; + +for (i =0 ; (name = tst_test->needs_devices[i]); i++) { +if (!getenv (name)) { +tst_res (TINFO ,"%s device env variable mising" , name); + exit =1 ; + } + } +if (exit) +tst_brk (TCONF ,"Device(s) not passed to the test" ); + } +if (tst_test->format_device) tst_test->needs_device =1 ;
Signature · 1 line
2.24.1
PATCH 2/2 device_drivers/uart01: Add uart01 test
In reply to Cyril Hrubis--- runtest/kernel_misc | 5 + .../kernel/device-drivers/uart/.gitignore | 1 + testcases/kernel/device-drivers/uart/Makefile | 4 + testcases/kernel/device-drivers/uart/uart01.c | 522 ++++++++++++++++++ 4 files changed, 532 insertions(+) create mode 100644 testcases/kernel/device-drivers/uart/.gitignore create mode 100644 testcases/kernel/device-drivers/uart/Makefile create mode 100644 testcases/kernel/device-drivers/uart/uart01.c
runtest/kernel_misc +5 -0
@@ -13,3 +13,8 @@ zram01 zram01.sh zram02 zram02.sh zram03 zram03 umip_basic_test umip_basic_test +uart01_9600 uart01 -b 9600 +uart01_19200 uart01 -b 19200 +uart01_38400 uart01 -b 38400 +uart01_57600 uart01 -b 57600 +uart01_115200 uart01 -b 115200
testcases/kernel/device-drivers/uart/.gitignore new file +1 -0
@@ -0,0 +1 @@ +uart01
testcases/kernel/device-drivers/uart/Makefile new file +4 -0
@@ -0,0 +1,4 @@ + +top_srcdir ?= ../../../.. +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/device-drivers/uart/uart01.c new file +522 -0
522 lines not on this page · raw message
Signature · 1 line
2.24.1
PATCH 2/2 device_drivers/uart01: Add uart01 test
Hi Cyril,
runtest/kernel_misc zram01 zram01.sh · line 20
Quoted 5 lines
runtest/kernel_misc +5
-0+uart01_9600 uart01 -b 9600 +uart01_19200 uart01 -b 19200 +uart01_38400 uart01 -b 38400 +uart01_57600 uart01 -b 57600 +uart01_115200 uart01 -b 115200
on all speeds.
Thanks for porting serialcheck.c to LTP.
Kind regards,
Petr
PATCH 2/2 device_drivers/uart01: Add uart01 test
In reply to Cyril HrubisHi Cyril:
Thank you porting the serialcheck.c into LTP
I am sorry to find the serialcheck have not LOOPBACK mode support the LOOPBACK mode is a better test than HW flow , because most machine's uart have not connect the Rx & TX
in LOOPBACK mode. we test the uart port directly, So we can test one uart port Rx and Tx functions at the same time .
here is the diff serialcheck with loopback patch
So I'd prefer use loopback mode test the uart in case.
$ diff serialcheck.c serialcheck-with-loopback.c 14a15,16
Quoted 2 lines
#define
TIOCM_LOOP0x8000
42a45
Quoted 1 line
unsigned char loopback;
53a57
Quoted 1 line
{"loopback", 'k', NULL, 0, "loopback mode", 0},69a74
Quoted 1 line
go->loopback = 0;
115a121,123
Quoted 3 lines
case 'k':
go->loopback = 1;
break;316c324
< ret = poll(&pfd, 1, 10 * 1000);
---
Quoted 1 line
ret = poll(&pfd, 1, 100 * 1000);
421a430
Quoted 1 line
unsigned int mcr;
489a499,511
Quoted 5 lines
if (opts.loopback) {
ret = ioctl(fd, TIOCMGET, &mcr);
if (ret < 0)
die("mcr get failed: %m\n");Quoted 8 lines
mcr |= TIOCM_LOOP;
ret = ioctl(fd, TIOCMSET, &mcr);
if (ret < 0)
die ("mcr set failed: %m\n");
}514a537,542
Quoted 6 lines
if(opts.loopback){
mcr &= ~(TIOCM_LOOP);
ret = ioctl(fd,TIOCMSET,&mcr);
}
if(ret)
printf("disabling loopback failed:%m\n");Cyril Hrubis <[email protected]> ?2020?3?27??? ??9:47???
Quoted 589 lines
Signed-off-by Cyril Hrubis <[email protected]>--- runtest/kernel_misc | 5 + .../kernel/device-drivers/uart/.gitignore | 1 + testcases/kernel/device-drivers/uart/Makefile | 4 + testcases/kernel/device-drivers/uart/uart01.c | 522 ++++++++++++++++++ 4 files changed, 532 insertions(+) create mode 100644 testcases/kernel/device-drivers/uart/.gitignore create mode 100644 testcases/kernel/device-drivers/uart/Makefile create mode 100644 testcases/kernel/device-drivers/uart/uart01.cruntest/kernel_misc +5
-0@@ -13,3 +13,8 @@ zram01 zram01.sh zram02 zram02.sh zram03 zram03 umip_basic_test umip_basic_test +uart01_9600 uart01 -b 9600 +uart01_19200 uart01 -b 19200 +uart01_38400 uart01 -b 38400 +uart01_57600 uart01 -b 57600 +uart01_115200 uart01 -b 115200testcases/kernel/device-drivers/uart/.gitignore new file +1
-0@@ -0,0 +1 @@ +uart01testcases/kernel/device-drivers/uart/Makefile new file +4
-0@@ -0,0 +1,4 @@ + +top_srcdir ?= ../../../.. +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mktestcases/kernel/device-drivers/uart/uart01.c new file +44
-0@@ -0,0 +1,522 @@ +// SPDX-License-Identifier: GPL-2.0-only + +/* +Copyright (c) 2014 Sebastian Andrzej Siewior <[email protected]> +Copyright (c) 2020 Cyril Hrubis <[email protected]> + +*/ + +#include <stdio.h> +#include <ctype.h> +#include <string.h> +#include <stdlib.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <termios.h> +#include <stdarg.h> +#include <unistd.h> +#include <sys/mman.h> +#include <stdint.h> +#include <poll.h> +#include <sys/ioctl.h> +#include <linux/serial.h> + +#include "tst_test.h" + +static const char hex_asc[] ="0123456789abcdef" ; +#define hex_asc_lo (x) hex_asc[((x) & 0x0f)] +#define hex_asc_hi (x) hex_asc[((x) & 0xf0) >> 4] + +struct g_opt { +char *uart_dev; +char *file_trans; +int baud_rate; +unsigned int loops; +unsigned char hwflow; +unsigned char do_termios; +#define MODE_TX_ONLY (1 << 0) +#define MODE_RX_ONLY (1 << 1) +#define MODE_DUPLEX (MODE_TX_ONLY | MODE_RX_ONLY) +unsigned int mode; +unsigned char *cmp_buff; +}; + +static int vscnprintf(char *buf, size_t size, const char *fmt, va_listargs)
testcases/kernel/device-drivers/uart/uart01.c new file +63
-0+{ +int i; + + i =vsnprintf (buf, size, fmt, args); + +if (i < (int )size) +return i; +if (size !=0 ) +return size -1 ; +return 0 ; +} + +static int scnprintf (char *buf,size_t size,const char *fmt, ...) +{ +va_list args; +int i; + +va_start (args, fmt); + i =vscnprintf (buf, size, fmt, args); +va_end (args); + +return i; +} + + +static void hex_dump_to_buffer (const void *buf,int len,int rowsize, +int groupsize,char *linebuf,int linebuflen,int ascii) +{ +const uint8_t *ptr = buf; +uint8_t ch; +int j, lx =0 ; +int ascii_column; + +if (rowsize !=16 && rowsize !=32 ) + rowsize =16 ; + +if (!len) + goto nil; +if (len > rowsize)/* limit to one line at a time */ + len = rowsize; +if ((len % groupsize) !=0 )/* no mixed size output */ + groupsize =1 ; + +switch (groupsize) { +case 8 : { +const uint64_t *ptr8 = buf; +int ngroups = len / groupsize; + +for (j =0 ; j < ngroups; j++) + lx +=scnprintf (linebuf + lx, linebuflen - lx, +"%s%16.16llx" , j ?" " :"" , + (unsigned long long )*(ptr8 + j)); + ascii_column =17 * ngroups +2 ; +break ; + } + +case 4 : { +const uint32_t *ptr4 = buf; +int ngroups = len / groupsize; + +for (j =0 ; j < ngroups; j++) + lx += scnprintf(linebuf + lx, linebuflen - lx, + "%s%8.8x", j ? " " : "", *(ptr4 +j));
testcases/kernel/device-drivers/uart/uart01.c new file +11
-0+ ascii_column =9 * ngroups +2 ; +break ; + } + +case 2 : { +const uint16_t *ptr2 = buf; +int ngroups = len / groupsize; + +for (j =0 ; j < ngroups; j++) + lx += scnprintf(linebuf + lx, linebuflen - lx, + "%s%4.4x", j ? " " : "", *(ptr2 +j));
testcases/kernel/device-drivers/uart/uart01.c new file +55
-0+ ascii_column =5 * ngroups +2 ; +break ; + } + +default : +for (j =0 ; (j < len) && (lx +3 ) <= linebuflen; j++) { + ch = ptr[j]; + linebuf[lx++] =hex_asc_hi (ch); + linebuf[lx++] =hex_asc_lo (ch); + linebuf[lx++] =' ' ; +if (j ==7 ) + linebuf[lx++] =' ' ; + } +if (j) + lx--; + + ascii_column =3 * rowsize +2 +2 ; +break ; + } +if (!ascii) + goto nil; + +while (lx < (linebuflen -1 ) && lx < (ascii_column -1 )) + linebuf[lx++] =' ' ; +for (j =0 ; (j < len) && (lx +2 ) < linebuflen; j++) { + ch = ptr[j]; + linebuf[lx++] = (isascii (ch) &&isprint (ch)) ? ch :'.' ; + } +nil: + linebuf[lx++] ='\0' ; +} + +static void print_hex_dump (const void *buf,int len,int offset) +{ +const uint8_t *ptr = buf; +int i, linelen, remaining = len; +char linebuf[32 *3 +2 +32 +2 +1 ]; +int rowsize =16 ; +int groupsize =1 ; + +if (rowsize !=16 && rowsize !=32 ) + rowsize =16 ; + +for (i =0 ; i < len; i += rowsize) { + linelen =MIN (remaining, rowsize); + remaining -= rowsize; + +hex_dump_to_buffer (ptr + i, linelen, rowsize, groupsize, + linebuf,sizeof (linebuf),1 ); + +printf ("%.8x: %s\n" , i + offset, linebuf); + } +} + +static int stress_test_uart_once(struct g_opt *opts, int fd, unsignedchar *data,
testcases/kernel/device-drivers/uart/uart01.c new file +34
-0+ off_t data_len) +{ + unsigned char *cmp_data = opts->cmp_buff; + ssize_t size; + int wait_rx; + int wait_tx; + ssize_t progress_rx = 0; + ssize_t progress_tx = 0; + unsigned int reads = 0; + unsigned int writes = 0; + + do { + struct pollfd pfd = { + .fd = fd, + }; + int ret; + + if (opts->mode & MODE_RX_ONLY && progress_rx < data_len) { + pfd.events |= POLLIN; + wait_rx = 1; + } else { + wait_rx = 0; + } + + if (opts->mode & MODE_TX_ONLY && progress_tx < data_len) { + pfd.events |= POLLOUT; + wait_tx = 1; + } else { + wait_tx = 0; + } + + ret = poll(&pfd, 1, 10 * 1000); + if (ret == 0) { + tst_res(TFAIL, "timeout, RX/TX: %zd/%zd\n",
progress_rx,progress_tx);testcases/kernel/device-drivers/uart/uart01.c new file +9
-0+break ; + } +if (ret <0 ) { +tst_res (TFAIL |TERRNO ,"poll() failed" ); +return 1 ; + } + +if (pfd.revents &POLLIN ) { + size = read(fd, cmp_data + progress_rx, data_len -
progress_rx);testcases/kernel/device-drivers/uart/uart01.c new file +13
-0+if (size <0 ) { +tst_res (TFAIL |TERRNO ,"read() failed" ); +return 1 ; + } + reads++; + progress_rx += size; +if (progress_rx >= data_len) + wait_rx =0 ; + } + +if (pfd.revents &POLLOUT ) { + + size = write(fd, data + progress_tx, data_len -
progress_tx);testcases/kernel/device-drivers/uart/uart01.c new file +33
-0+if (size <0 ) { +tst_res (TFAIL |TERRNO ,"write() failed" ); +return 1 ; + } + writes++; + progress_tx += size; +if (progress_tx >= data_len) + wait_tx =0 ; + } + }while (wait_rx || wait_tx); + +tst_res (TINFO ,"Needed %u reads %u writes " , reads, writes); + +if (opts->mode &MODE_RX_ONLY ) { +unsigned int i; +int found =0 ; +unsigned int min_pos; +unsigned int max_pos; + +if (!memcmp (data, cmp_data, data_len)) { +tst_res (TPASS ,"RX passed" ); +return 0 ; + } + +for (i =0 ; i < data_len && !found; i++) { +if (data[i] != cmp_data[i]) { + found =1 ; +break ; + } + } + +if (!found) { + tst_res(TFAIL, "memcmp() didn't match but manualcmp did");
testcases/kernel/device-drivers/uart/uart01.c new file +14
-0+return 1 ; + } + + max_pos = (i & ~0xfULL ) +16 *3 ; +if (max_pos > data_len) + max_pos = data_len; + + min_pos = i & ~0xfULL ; +if (min_pos >16 *3 ) + min_pos -=16 *3 ; +else + min_pos =0 ; + + tst_res(TFAIL, "Oh oh, inconsistency at pos %d (0x%x)", i,i);
testcases/kernel/device-drivers/uart/uart01.c new file +6
-0+ +printf ("\nOriginal sample:\n" ); +print_hex_dump (data + min_pos, max_pos - min_pos, min_pos); + +printf ("\nReceived sample:\n" ); + print_hex_dump(cmp_data + min_pos, max_pos - min_pos,
min_pos);testcases/kernel/device-drivers/uart/uart01.c new file +10
-0+return 1 ; + } + +if (opts->mode &MODE_TX_ONLY ) +tst_res (TPASS ,"TX passed" ); + +return 0 ; +} + +static int stress_test_uart(struct g_opt *opts, int fd, unsigned char*data,
off_tdata_len)testcases/kernel/device-drivers/uart/uart01.c new file +18
-0+{ +unsigned int loops =0 ; +int status; + + opts->cmp_buff =SAFE_MALLOC (data_len); +memset (opts->cmp_buff,0 , data_len); + +do { + status =stress_test_uart_once (opts, fd, data, data_len); +memset (opts->cmp_buff,0 , data_len); + }while (++loops < opts->loops && !status); + +free (opts->cmp_buff); + +return status; +} + +static int setup_uart(struct g_opt *opts, int open_mode, struct termios
*old_term)testcases/kernel/device-drivers/uart/uart01.c new file +20
-0+{ +struct termios new_term; +int fd; +int ret; + +tst_res (TINFO ,"Setting up %s speed %u hwflow=%u" , + opts->uart_dev, opts->baud_rate, opts->hwflow); + + fd =SAFE_OPEN (opts->uart_dev, open_mode |O_NONBLOCK ); + + ret =tcgetattr (fd, old_term); +if (ret <0 ) +tst_brk (TBROK ,"tcgetattr() failed: %m\n" ); + + new_term = *old_term; + +/* or c_cflag |= BOTHER and c_ospeed for any speed */ + ret =cfsetspeed (&new_term, opts->baud_rate); +if (ret <0 ) + tst_brk(TBROK, "cfsetspeed(, %u) failed %m\n",
opts->baud_rate);testcases/kernel/device-drivers/uart/uart01.c new file +87
-0+cfmakeraw (&new_term); + new_term.c_cflag |=CREAD ; +if (opts->hwflow) + new_term.c_cflag |=CRTSCTS ; +else + new_term.c_cflag &= ~CRTSCTS ; + new_term.c_cc[VMIN ] =64 ; + new_term.c_cc[VTIME ] =8 ; + + ret =tcsetattr (fd,TCSANOW , &new_term); +if (ret <0 ) +tst_brk (TBROK ,"tcsetattr failed: %m\n" ); + +if (opts->do_termios) { + ret =tcflush (fd,TCIFLUSH ); +if (ret <0 ) +tst_brk (TBROK ,"tcflush failed: %m\n" ); + } + + ret =fcntl (fd,F_SETFL ,0 ); +if (ret) +printf ("Failed to remove nonblock mode\n" ); + +return fd; +} + +static void restore_uart (int fd,struct termios *old_term) +{ +int ret =tcsetattr (fd,TCSAFLUSH , old_term); +if (ret) +printf ("tcsetattr() of old ones failed: %m\n" ); +} + +static void print_counters (const char *prefix, +struct serial_icounter_struct *old, +struct serial_icounter_struct *new) +{ +#define CNT (x) (new->x - old->x) +printf ("%scts: %d dsr: %d rng: %d dcd: %d rx: %d tx: %d " +"frame %d ovr %d par: %d brk: %d buf_ovrr: %d\n" , prefix, +CNT (cts),CNT (dsr),CNT (rng),CNT (dcd),CNT (rx), +CNT (tx),CNT (frame),CNT (overrun),CNT (parity), +CNT (brk),CNT (buf_overrun)); +#undef CNT +} + +static struct g_opt opts = { + .baud_rate =115200 , + .loops =1 , + .do_termios =1 , +}; + +static char *uart_rx; +static char *uart_tx; + +unsigned char *data; +static long data_len; + +void run (void ) +{ +struct serial_icounter_struct old_counters; +struct serial_icounter_struct new_counters; +int ret, fd_rx, fd_tx; +struct termios old_term_rx, old_term_tx; + +struct g_opt opts_in = opts; +struct g_opt opts_out = opts; + + opts_in.uart_dev = uart_rx; + opts_out.uart_dev = uart_tx; + + opts_in.mode =MODE_RX_ONLY ; + opts_out.mode =MODE_TX_ONLY ; + + fd_rx =setup_uart (&opts_in,O_RDONLY , &old_term_rx); + +if (!strcmp (uart_rx, uart_tx)) + fd_tx =SAFE_OPEN (uart_tx,O_WRONLY ); +else + fd_tx =setup_uart (&opts_out,O_WRONLY , &old_term_tx); + +if (!SAFE_FORK ()) { +ioctl (fd_rx,TIOCGICOUNT , &old_counters); +stress_test_uart (&opts_in, fd_rx, data, data_len); + ret =ioctl (fd_rx,TIOCGICOUNT , &new_counters); +if (ret >0 ) + print_counters("RX:", &old_counters,
&new_counters);testcases/kernel/device-drivers/uart/uart01.c new file +9
-0+exit (0 ); + } + +if (!SAFE_FORK ()) { +ioctl (fd_tx,TIOCGICOUNT , &old_counters); +stress_test_uart (&opts_out, fd_tx, data, data_len); + ret =ioctl (fd_tx,TIOCGICOUNT , &new_counters); +if (ret >0 ) + print_counters("TX:", &old_counters,
&new_counters);testcases/kernel/device-drivers/uart/uart01.c new file +94
-0+exit (0 ); + } + +SAFE_WAIT (NULL ); +SAFE_WAIT (NULL ); + +restore_uart (fd_rx, &old_term_rx); + +if (strcmp (uart_rx, uart_tx)) +restore_uart (fd_tx, &old_term_tx); + +close (fd_rx); +close (fd_tx); +} + +static void map_file (const char *fname) +{ +struct stat st; +int fd; + + fd =SAFE_OPEN (fname,O_RDONLY ); + +SAFE_FSTAT (fd, &st); + + data_len = st.st_size; + + data =SAFE_MMAP (NULL , data_len,PROT_READ , +MAP_SHARED |MAP_LOCKED |MAP_POPULATE , fd,0 ); + +tst_res (TINFO ,"Mapped file '%s' size %li bytes" , fname, data_len); + +SAFE_CLOSE (fd); +} + +static void map_buffer (long buf_size) +{ +size_t i; + + data_len = buf_size; + + data =SAFE_MMAP (NULL , data_len,PROT_READ |PROT_WRITE , +MAP_ANONYMOUS |MAP_SHARED |MAP_LOCKED ,-1 ,0 ); + +long *p = (void *)data; + +srandom (time (NULL )); + +for (i =0 ; i < data_len /sizeof (long ); i++) + p[i] =random (); + +tst_res (TINFO ,"Mapped anynymous memory size %li bytes" , data_len); +} + +static char *baud_rate; +static char *hwflow; +static char *fname; +static char *buf_size; + +static void setup (void ) +{ +long size =1024 ; + +if (baud_rate) +tst_parse_int (baud_rate, &(opts.baud_rate),0 ,INT_MAX ); + +if (hwflow) + opts.hwflow =1 ; + +if (fname && buf_size) +tst_brk (TBROK ,"Only one of -f and -s could be set!" ); + +if (buf_size) +tst_parse_long (buf_size, &size,0 ,LONG_MAX ); + + uart_rx =getenv ("UART_RX" ); + uart_tx =getenv ("UART_TX" ); + +if (fname) +map_file (fname); +else +map_buffer (size); +} + +static struct tst_test test = { + .setup = setup, + .test_all = run, + .options = (struct tst_option []) { + {"b:" , &baud_rate,"-b Baud rate (9600, ...)" }, + {"w" , &hwflow ,"-w Enable hwflow (RTS/CTS)" }, + {"f:" , &fname,"-f Binary file for transfers" }, + {"s:" , &buf_size,"-s Binary buffer size" }, + {} + }, + .needs_devices = (const char *const []) {"UART_RX" ,"UART_TX" ,NULL},
testcases/kernel/device-drivers/uart/uart01.c new file +2
-1+ .forks_child = 1, +}; --
Quoted 3 lines
2.24.1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200328/58f85ae9/attachment-0001.htm>
PATCH 2/2 device_drivers/uart01: Add uart01 test
Hi!
Quoted 9 lines
Thank you porting the
serialcheck.cinto LTP
I am sorry to find the serialcheck have not LOOPBACK mode support the LOOPBACK mode is a better test than HW flow , because most machine's uart have not connect the Rx & TX
in LOOPBACK mode. we test the uart port directly, So we can test one uart port Rx and Tx functions at the same time .
here is the diff serialcheck with loopback patch
So I'd prefer use loopback mode test the uart in case.$ diff serialcheck.c serialcheck-with-loopback.c
Thanks for the hint, I had no idea that subset serial port hardware has a loopback test that could be enabled in modem control register which is meant for testing. I will have a closer look tomorrow.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 2/2 device_drivers/uart01: Add uart01 test
Hi!
Quoted 10 lines
Quoted 9 lines
Thank you porting the
serialcheck.cinto LTP
I am sorry to find the serialcheck have not LOOPBACK mode support the LOOPBACK mode is a better test than HW flow , because most machine's uart have not connect the Rx & TX
in LOOPBACK mode. we test the uart port directly, So we can test one uart port Rx and Tx functions at the same time .
here is the diff serialcheck with loopback patch
So I'd prefer use loopback mode test the uart in case.$ diff serialcheck.c serialcheck-with-loopback.c
Quoted 3 lines
Thanks for the hint, I had no idea that subset serial port hardware has a loopback test that could be enabled in modem control register which is meant for testing. I will have a closer look tomorrow.
If I understand this properly if we set a bit in the modem control register we will test mostly the circuits between CPU and UART controller which is better than nothing, but we are not really testing if the port speed was set correctly since the data are just being copied between registers in the UART controller, so it does not make sense to change the speed in this mode. Or am I mistaken?
Also it does not seem to work for me and I've tried with both serial ports on my desktop PC as well as with USB-to-Serial dongle. I can set the bit just fine but loopback does not work.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 2/2 device_drivers/uart01: Add uart01 test
Quoted 10 lines
If I understand this properly if we set a bit in the modem control register we will test mostly the circuits between CPU and UART controller which is better than nothing, but we are not really testing if the port speed was set correctly since the data are just being copied between registers in the UART controller, so it does not make sense to change the speed in this mode. Or am I mistaken?
Also it does not seem to work for me and I've tried with both serial ports on my desktop PC as well as with USB-to-Serial dongle. I can set the bit just fine but loopback does not work.
In the loopback mode , the data will be transferred in buffer ,and back to CPU
by FIFO way.
I understand the test flow is CPU->uart Tx-> buffer file->uart Rx->CPU, so it does make sense to the uart driver .
BTW? I found the latest seriacheck git is
https://github.com/nsekhar/serialcheck.git
and I test on my arm64 machine of sprdtream. and it does works. the test log I had send in another patch
https://patchwork.ozlabs.org/patch/1264553/
Cyril Hrubis <[email protected]> ?2020?4?1??? ??2:08???
Quoted 24 lines
Hi!
Quoted 3 lines
Quoted 3 lines
Thank you porting the
serialcheck.cinto LTP
I am sorry to find the serialcheck have not LOOPBACK mode support the LOOPBACK mode is a better test than HW flow , because mostmachine's
Quoted 2 lines
Quoted 2 lines
uart have not connect the Rx & TX
in LOOPBACK mode. we test the uart port directly, So we can test oneuart
Quoted 8 lines
Quoted 4 lines
port Rx and Tx functions at the same time . here is the diff serialcheck with loopback patch So I'd prefer use loopback mode test the uart in case.
$ diff serialcheck.c serialcheck-with-loopback.cThanks for the hint, I had no idea that subset serial port hardware has a loopback test that could be enabled in modem control register which is meant for testing. I will have a closer look tomorrow.
If I understand this properly if we set a bit in the modem control register we will test mostly the circuits between CPU and UART controller which is better than nothing, but we are not really testing if the port speed was set correctly since the data are just being copied between registers in the UART controller, so it does not make sense to change the speed in this mode. Or am I mistaken?
Quoted 8 lines
Also it does not seem to work for me and I've tried with both serial ports on my desktop PC as well as with USB-to-Serial dongle. I can set the bit just fine but loopback does not work.
--
Cyril Hrubis
[email protected]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200401/70acecb6/attachment-0001.htm>
PATCH 2/2 device_drivers/uart01: Add uart01 test
Hi!
Quoted 11 lines
Quoted 10 lines
If I understand this properly if we set a bit in the modem control register we will test mostly the circuits between CPU and UART controller which is better than nothing, but we are not really testing if the port speed was set correctly since the data are just being copied between registers in the UART controller, so it does not make sense to change the speed in this mode. Or am I mistaken?
Also it does not seem to work for me and I've tried with both serial ports on my desktop PC as well as with USB-to-Serial dongle. I can set the bit just fine but loopback does not work.
Quoted 5 lines
In the loopback mode , the data will be transferred in buffer ,and back to CPU
by FIFO way.
I understand the test flow isCPU->uartTx-> bufferfile->uartRx->CPU, so it does make sense to the uart driver .
Indeed but it does not make sense tu run it with a different baud rates, since the data are not transmitted at all.
Quoted 5 lines
BTW??? I found the latest seriacheck git is
https://github.com/nsekhar/serialcheck.git
and I test on my arm64 machine of sprdtream. and it does works. the test log I had send in another patch
https://patchwork.ozlabs.org/patch/1264553/
Unfortunately it does not seem to work on my AMD based desktop at all, my guess is that the loopback bit is silently ignored by the hardware.
Which means that we cannot enable the test by default in loopback mode after all.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 2/2 device_drivers/uart01: Add uart01 test
Quoted 2 lines
Indeed but it does not make sense tu run it with a different baud rates, since the data are not transmitted at all.
The data exchanged between Tx|Rx and buffer have nothing to do with baudrate?
I think the baudrate is control Tx|Rx send and receive date rate to|from buffer.
Quoted 4 lines
Unfortunately it does not seem to work on my AMD based desktop at all, my guess is that the loopback bit is silently ignored by the hardware. Which means that we cannot enable the test by default in loopback mode after all
I will test on my laptop and feedback result today, if it does no work , we should
check the uart driver what different between x86 and arm64.
Cyril Hrubis <[email protected]> ?2020?4?1??? ??9:12???
Quoted 31 lines
Hi!
Quoted 7 lines
Quoted 6 lines
If I understand this properly if we set a bit in the modem control register we will test mostly the circuits between CPU and UART controller which is better than nothing, but we are not really testing if the port speed was set correctly since the data are just being copied between registers in the UART controller, so it does not make sense to change the speed in this mode. Or am I mistaken?
Quoted 5 lines
Quoted 3 lines
Also it does not seem to work for me and I've tried with both serial ports on my desktop PC as well as with USB-to-Serial dongle. I can set the bit just fine but loopback does not work.
In the loopback mode , the data will be transferred in buffer ,and back
to
Quoted 4 lines
CPU
by FIFO way.
I understand the test flow isCPU->uartTx-> bufferfile->uartRx->CPU, so it does make sense to the uart driver .Indeed but it does not make sense tu run it with a different baud rates, since the data are not transmitted at all.
Quoted 5 lines
BTW??? I found the latest seriacheck git is
https://github.com/nsekhar/serialcheck.git
and I test on my arm64 machine of sprdtream. and it does works. the test log I had send in another patch
https://patchwork.ozlabs.org/patch/1264553/Unfortunately it does not seem to work on my AMD based desktop at all, my guess is that the loopback bit is silently ignored by the hardware.
Quoted 7 lines
Which means that we cannot enable the test by default in loopback mode after all.
--
Cyril Hrubis
[email protected]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200402/662c8d47/attachment.htm>
PATCH 2/2 device_drivers/uart01: Add uart01 test
Hi!
Quoted 6 lines
Quoted 2 lines
Indeed but it does not make sense tu run it with a different baud rates, since the data are not transmitted at all.
The data exchanged between Tx|Rx and buffer have nothing to do with baudrate?
I think the baudrate is control Tx|Rx send and receive date rate to|from buffer.
That's what I'm not sure about, the documentation says that in loopback mode data written to the port immediatelly appears on the receiving end, which would mean that the uart speed does not matter at all.
Can you try a quick test? If you measure the time the test spends writing data in loopback mode for a different uart speeds and they do not differ the uart speed does not matter.
Quoted 6 lines
Quoted 4 lines
Unfortunately it does not seem to work on my AMD based desktop at all, my guess is that the loopback bit is silently ignored by the hardware. Which means that we cannot enable the test by default in loopback mode after all
I will test on my laptop and feedback result today, if it does no work , we should check the uart driver what different between x86 and arm64.
I bet that this differs chipset by chipset and I do not think there is anything wrong with the uart driver per se.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 2/2 device_drivers/uart01: Add uart01 test
Hi
I am sorry that when I run the serialcheck on my laptop, there always has some error as follow,which mean I cannot verify the serialcheck on my computer for now. Failed to ioctl(,TIOCGICOUNT,) -- test ttyUSB0 tcgetattr() failed: Input/output error -- test ttyS0 I am trying to find available machine and then run test.
Cyril Hrubis <[email protected]> ?2020?4?2??? ??5:31???
Quoted 22 lines
Hi!
Quoted 6 lines
Quoted 2 lines
Indeed but it does not make sense tu run it with a different baud rates, since the data are not transmitted at all.
The data exchanged between Tx|Rx and buffer have nothing to do with baudrate?
I think the baudrate is control Tx|Rx send and receive date rate to|from buffer.That's what I'm not sure about, the documentation says that in loopback mode data written to the port immediatelly appears on the receiving end, which would mean that the uart speed does not matter at all.
Can you try a quick test? If you measure the time the test spends writing data in loopback mode for a different uart speeds and they do not differ the uart speed does not matter.
Quoted 5 lines
Quoted 4 lines
Unfortunately it does not seem to work on my AMD based desktop at all, my guess is that the loopback bit is silently ignored by the hardware. Which means that we cannot enable the test by default in loopback mode after all
I will test on my laptop and feedback result today, if it does no work ,
we
Quoted 9 lines
Quoted 1 line
should check the uart driver what different between x86 and arm64.
I bet that this differs chipset by chipset and I do not think there is anything wrong with the uart driver per se.
--
Cyril Hrubis
[email protected]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200402/d38d2ef0/attachment.htm>
PATCH 2/2 device_drivers/uart01: Add uart01 test
Hi!
Quoted 4 lines
I am sorry that when I run the serialcheck on my laptop, there always has some error as follow,which mean I cannot verify the serialcheck on my computer for now. Failed to
ioctl(,TIOCGICOUNT,)-- test ttyUSB0
This one can be ignored, that just means that the counters are not implemented and the statistics are not printed at the test end.
Quoted 2 lines
tcgetattr()failed: Input/output error -- test ttyS0 I am trying to find available machine and then run test.
That looks like there is no UART to begin with.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 2/2 device_drivers/uart01: Add uart01 test
Hi Cyril:
Here is my test result, in this test we can make sure that the baudrate is needed in test.
the test hope help you
1. test ttyUSB0 in loopback use the same baudrate of Rx and Tx , test pass with 5loop
root@Y50:/home/gcx/project/serialcheck# serialcheck -b 115200 -d /dev/ttyUSB0 -f binary -l 5 -m r -k Needed 64 reads 0 writes loops 5 / 5 Failed to ioctl(,TIOCGICOUNT,) gcx@Y50:~/project/serialcheck$ serialcheck -b 115200 -d /dev/ttyUSB0 -f binary -m t -l 5 -k Needed 0 reads 1 writes loops 5 / 5 Failed to ioctl(,TIOCGICOUNT,) 2. test ttyUSB0 in loopback use different baudrate ,Error at the fist loop root@Y50:/home/gcx/project/serialcheck# serialcheck -b 115200 -d /dev/ttyUSB0 -f binary -l 5 -m r -k & [1] 20764 gcx@Y50:~/project/serialcheck$ serialcheck -b 115200 -d /dev/ttyUSB0 -f binary -m t -l 5 -k Needed 0 reads 1 writes loops 5 / 5 Failed to ioctl(,TIOCGICOUNT,) Needed 64 reads 0 writes Oh oh, inconsistency at pos 502 (0x1f6).
Original sample:000001c0: 91 95 eb b6 82 e9 2a e6 16 5a da a3 c2 51 c4 c9 ......*..Z...Q..000001d0: c5 51 e1 b7 c9 76 67 d5 09 57 80 77 eb bf 6d d7 .Q...vg..W.w..m.000001e0: 08 a6 7b fd 52 1b 12 8e f2 50 c1 b7 a7 52 35 39 ..{.R....P...R59000001f0: 54 d4 50 96 49 55 35 30 33 52 80 89 8e a9 1e a2 T.P.IU503R......
00000200: 2c a5 0d 1a 26 f6 ea 77 a4 4a b9 69 34 17 cc bc ,...&..w.J.i4...
00000210: e2 6e 0c f9 e1 11 39 9f fd ce 94 9e 19 30 f4 1c .n....9......0..
Received sample:000001c0: 91 95 eb b6 82 e9 2a e6 16 5a da a3 c2 51 c4 c9 ......*..Z...Q..000001d0: c5 51 e1 b7 c9 76 67 d5 09 57 80 77 eb bf 6d d7 .Q...vg..W.w..m.000001e0: 08 a6 7b fd 52 1b 12 8e f2 50 c1 b7 a7 52 35 39 ..{.R....P...R59000001f0: 54 d4 50 96 49 55 06 9a 92 01 89 8e a9 1e a2 2c T.P.IU.........,
00000200: a5 0d 1a 26 f6 ea 77 a4 4a b9 69 34 17 cc bc e2 ...&..w.J.i4....
00000210: 6e 0c f9 e1 11 39 9f fd ce 94 9e 19 30 f4 1c 74 n....9......0..t
loops 1 / 5
Cyril Hrubis <[email protected]> ?2020?4?2??? ??7:22???
Quoted 9 lines
Hi!
Quoted 4 lines
I am sorry that when I run the serialcheck on my laptop, there always has some error as follow,which mean I cannot verify the serialcheck on my computer for now. Failed to
ioctl(,TIOCGICOUNT,)-- test ttyUSB0This one can be ignored, that just means that the counters are not implemented and the statistics are not printed at the test end.
Quoted 9 lines
Quoted 2 lines
tcgetattr()failed: Input/output error -- test ttyS0 I am trying to find available machine and then run test.That looks like there is no UART to begin with.
--
Cyril Hrubis
[email protected]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20200403/758ca0cd/attachment.htm>
PATCH 2/2 device_drivers/uart01: Add uart01 test
Quoted 19 lines
Cyril Hrubis <[email protected]> ?2020?4?2??? ??7:22???
Quoted 18 lines
Hi!
Quoted 4 lines
I am sorry that when I run the serialcheck on my laptop, there always has some error as follow,which mean I cannot verify the serialcheck on my computer for now. Failed to
ioctl(,TIOCGICOUNT,)-- test ttyUSB0This one can be ignored, that just means that the counters are not implemented and the statistics are not printed at the test end.
Quoted 2 lines
tcgetattr()failed: Input/output error -- test ttyS0 I am trying to find available machine and then run test.That looks like there is no UART to begin with.
--
Cyril Hrubis
[email protected]
Hi Cyril:
I would like to know how is it going? lastweek I send the test data . hope it will helpful.
In my test result we can found if Rx Tx in different rate, the test will fail.
1. test ttyUSB0 in loopback use the same baudrate of Rx and Tx , test pass with 5loop
root@Y50:/home/gcx/project/serialcheck# serialcheck -b 115200 -d /dev/ttyUSB0 -f binary -l 5 -m r -k Needed 64 reads 0 writes loops 5 / 5 Failed to ioctl(,TIOCGICOUNT,) gcx@Y50:~/project/serialcheck$ serialcheck -b 115200 -d /dev/ttyUSB0 -f binary -m t -l 5 -k Needed 0 reads 1 writes loops 5 / 5 Failed to ioctl(,TIOCGICOUNT,) 2. test ttyUSB0 in loopback use different baudrate ,Error at the fist loop root@Y50:/home/gcx/project/serialcheck# serialcheck -b 9600 -d /dev/ttyUSB0 -f binary -l 5 -m r -k & [1] 20764 gcx@Y50:~/project/serialcheck$ serialcheck -b 115200 -d /dev/ttyUSB0 -f binary -m t -l 5 -k Needed 0 reads 1 writes loops 5 / 5 Failed to ioctl(,TIOCGICOUNT,) Needed 64 reads 0 writes Oh oh, inconsistency at pos 502 (0x1f6).
Original sample:
000001c0: 91 95 eb b6 82 e9 2a e6 16 5a da a3 c2 51 c4 c9 ......*..Z...Q..
000001d0: c5 51 e1 b7 c9 76 67 d5 09 57 80 77 eb bf 6d d7 .Q...vg..W.w..m.
000001e0: 08 a6 7b fd 52 1b 12 8e f2 50 c1 b7 a7 52 35 39 ..{.R....P...R59
000001f0: 54 d4 50 96 49 55 35 30 33 52 80 89 8e a9 1e a2 T.P.IU503R......
00000200: 2c a5 0d 1a 26 f6 ea 77 a4 4a b9 69 34 17 cc bc ,...&..w.J.i4...
00000210: e2 6e 0c f9 e1 11 39 9f fd ce 94 9e 19 30 f4 1c .n....9......0..Received sample:
000001c0: 91 95 eb b6 82 e9 2a e6 16 5a da a3 c2 51 c4 c9 ......*..Z...Q..
000001d0: c5 51 e1 b7 c9 76 67 d5 09 57 80 77 eb bf 6d d7 .Q...vg..W.w..m.
000001e0: 08 a6 7b fd 52 1b 12 8e f2 50 c1 b7 a7 52 35 39 ..{.R....P...R59
000001f0: 54 d4 50 96 49 55 06 9a 92 01 89 8e a9 1e a2 2c T.P.IU.........,
00000200: a5 0d 1a 26 f6 ea 77 a4 4a b9 69 34 17 cc bc e2 ...&..w.J.i4....
00000210: 6e 0c f9 e1 11 39 9f fd ce 94 9e 19 30 f4 1c 74 n....9......0..tloops 1 / 5
PATCH 2/2 device_drivers/uart01: Add uart01 test
Hi!
Quoted 1 line
I would like to know how is it going?
I had a time off and was planting plants in my garden, I will get back to the uart ASAP, but then we have a public holiday on Friday and Monday so I may not manage to do much until next week.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 2/2 device_drivers/uart01: Add uart01 test
Quoted 7 lines
I had a time off and was planting plants in my garden, I will get back to the uart ASAP, but then we have a public holiday on Friday and Monday so I may not manage to do much until next week.
--
Cyril Hrubis
[email protected]
Hi Cyril:
I had study the ltp execution framework and found that the LTP detection device is
not suitable for device driver test at present.
Like the UART test, I want have a auto-detect way to find the device needed to test
in the current running LtP machines.
Now I have test the uart case in several sprdtream Soc these board have different /dev/tty* device?and I nedd run in CI manual export device puzzled me to do the auto-test-job. moreover I wil porting other device driver testcases in the future. So can We expand the LTP detection ?
PATCH 2/2 device_drivers/uart01: Add uart01 test
Hi!
Quoted 11 lines
I had study the ltp execution framework and found that the LTP detection device is
not suitable for device driver test at present.
Like the UART test, I want have a auto-detect way to find the device needed to test
in the current running LtP machines.
Now I have test the uart case in several sprdtream Soc these board have different/dev/tty*device???and I nedd run in CI manual export device puzzled me to do the auto-test-job. moreover I wil porting other device driver testcases in the future. So can We expand the LTP detection ?
Sorry I haven't managed to work on this before it was time for LTP release. I will resume my work on this once LTP is released.
My generall idea is that the LTP framework will get a path to a directory with scripts that would be evaluated at test runtime and will return list of devices to test. These scripts will have to be supplied by the user as managing lab hardware is out of scope of the LTP framework.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 2/2 device_drivers/uart01: Add uart01 test
Cyril Hrubis <[email protected]> ?2020?5?11??? ??5:37???
Quoted 23 lines
Hi!
Quoted 11 lines
I had study the ltp execution framework and found that the LTP detection device is
not suitable for device driver test at present.
Like the UART test, I want have a auto-detect way to find the device needed to test
in the current running LtP machines.
Now I have test the uart case in several sprdtream Soc these board have different/dev/tty*device???and I nedd run in CI manual export device puzzled me to do the auto-test-job. moreover I wil porting other device driver testcases in the future. So can We expand the LTP detection ?Sorry I haven't managed to work on this before it was time for LTP release. I will resume my work on this once LTP is released.
My generall idea is that the LTP framework will get a path to a directory with scripts that would be evaluated at test runtime and will return list of devices to test. These scripts will have to be supplied by the user as managing lab hardware is out of scope of the LTP framework.
Quoted 3 lines
--
Cyril Hrubis
[email protected]
Thank you for your guidance?In the Next time, I will try to fork a process in serialcheck.c
So it can be test Tx & Rx at one time.And then to develop the detection scripts if hava a time
I'll keep you posted on the status.