JianyuWang0623 commented on PR #16992:
URL: https://github.com/apache/nuttx/pull/16992#issuecomment-3273230899

   > > ```
   > > 1. Selftest OK
   > > 2. CI
   > > ```
   > 
   > What is "selftest"? Can you please provide logs? What hardware did you 
test on.
   
   @linguini1 To provide additional context: this is actually a new feature 
currently under development in nuttx-apps. Once the development is completed, 
it will be upstreamed. It would be greatly appreciated if you could spare some 
time to help review it then. Below are the test scenarios for standalone 
building:
   - Board: `qemu-armv8a:fastboot` (Actually, any board is okay—it’s 
hardware-independent(RAMMTD).)
   - Depends:
     - `CONFIG_SIGNAL_FD=y`
     - `CONFIG_SIG_DEFAULT=y`
   
   - Selftest code (based on examples/hello)
   
   ```diff
   diff --git a/examples/hello/hello_main.c b/examples/hello/hello_main.c
   index fd194a623a..5e7c976b36 100644
   --- a/examples/hello/hello_main.c
   +++ b/examples/hello/hello_main.c
   @@ -25,7 +25,25 @@
     
****************************************************************************/
    
    #include <nuttx/config.h>
   +#include <nuttx/mtd/configdata.h>
   +#include <nuttx/mtd/mtd.h>
   +
   +#include <fcntl.h>
    #include <stdio.h>
   +#include <syslog.h>
   +#include <sys/epoll.h>
   +#include <sys/ioctl.h>
   +#include <sys/param.h>
   +#include <sys/stat.h>
   +#include <sys/types.h>
   +
   
+/****************************************************************************
   + * Pre-processor Definitions
   + 
****************************************************************************/
   +
   +#define NVS_PATH "/dev/config"
   +#define TEST_KEY   "testkey"
   +#define TEST_VALUE "testvalue"
    
    
/****************************************************************************
     * Public Functions
   @@ -38,5 +56,49 @@
    int main(int argc, FAR char *argv[])
    {
      printf("Hello, World!!\n");
   +
   +  struct epoll_event events[1];
   +  struct config_data_s data;
   +  int epfd;
   +  int nvs_fd;
   +  int ret;
   +
   +  epfd = epoll_create1(EPOLL_CLOEXEC);
   +  if (epfd < 0)
   +    {
   +      syslog(LOG_ERR, "epoll_create1");
   +      return -errno;
   +    }
   +
   +  nvs_fd = open(NVS_PATH, 0);
   +  if (nvs_fd < 0)
   +    {
   +      syslog(LOG_ERR, "open mtdcfg");
   +      return -errno;
   +    }
   +
   +  events[0].events = POLLPRI;
   +  events[0].data.fd = nvs_fd;
   +  if (epoll_ctl(epfd, EPOLL_CTL_ADD, nvs_fd, &events[0]) < 0)
   +    {
   +      syslog(LOG_ERR, "add interest %d", errno);
   +      return -errno;
   +    }
   +
   +  ret = epoll_wait(epfd, events, nitems(events), 0);
   +  syslog(LOG_INFO, "First wait, should return zero, actually: %d", ret);
   +
   +  strlcpy(data.name, TEST_KEY, sizeof(data.name));
   +  data.configdata = (void *)TEST_VALUE;
   +  data.len = strlen(TEST_VALUE) + 1;
   +  ret = ioctl(nvs_fd, CFGDIOC_SETCONFIG, &data);
   +  if (ret < 0)
   +    {
   +      syslog(LOG_ERR, "set property");
   +    }
   +
   +  ret = epoll_wait(epfd, events, nitems(events), 0);
   +  syslog(LOG_INFO, "Wait after set, should greater than zero, actually: 
%d", ret);
   +
      return 0;
    }
   ```
   - Log - Without this patch
   ```
   nsh> hello
   Hello, World!!
   [    4.570000] [37] [ 4] hello: First wait, should return zero, actually: 0
   [    4.570000] [37] [ 4] hello: Wait after set, should greater than zero, 
actually: 0
   ```
   - Log - With this patch
   ```
   nsh> hello
   Hello, World!!
   [    6.950000] [53] [ 4] hello: First wait, should return zero, actually: 0
   [    6.950000] [53] [ 4] hello: Wait after set, should greater than zero, 
actually: 1
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to