UPDATE: I did another experiment with container, and find only with next way I could make this case PASS:

 

docker run --net=host -d --init --privileged -v /dev:/dev --interactive -t --name=abc2 --hostname=abc2 --mount=type=bind,source=/etc/localtime,destination=/etc/localtime,readonly=true atline/mytest:1 bash

 

Then, in this container run next command, it could successfully find the MTP device

 

adb wait-for-device && sleep 10 && ./vts-tradefed run singleCommand vts --logcat-on-failure --skip-device-info --module "HalUsbGadgetV1_0HostTest" -t com.android.tests.usbgadget.HalUsbGadgetV1_0HostTest#testMtp -a arm64-v8a

 

But, I don’t know how to make it align with LAVA which need to use udev to add device to container, could you have a look? Thanks.

 

From: Larry Shen
Sent: Tuesday, January 12, 2021 4:30 PM
To: 'lava-users@lists.lavasoftware.org' <lava-users@lists.lavasoftware.org>; 'Milosz Wasilewski' <milosz.wasilewski@linaro.org>; antonio.terceiro@linaro.org
Subject: RE: Ask android vts test link in docker test shell.

 

Update the detail command to reproduce the issue:

 

./vts-tradefed run singleCommand vts --logcat-on-failure --skip-device-info --module "HalUsbGadgetV1_0HostTest" -t com.android.tests.usbgadget.HalUsbGadgetV1_0HostTest#testMtp -a arm64-v8a

 

From: Larry Shen
Sent: Monday, January 11, 2021 3:57 PM
To: 'lava-users@lists.lavasoftware.org' <lava-users@lists.lavasoftware.org>; 'Milosz Wasilewski' <milosz.wasilewski@linaro.org>
Subject: RE: Ask android vts test link in docker test shell.

 

Hi, guys,

 

I have a further look for this issue, and found the time the kernel device appear in host & the time the kernel device appear in container is different.

 

For host:

$ stat 3-8:1.0

  File: 3-8:1.0

  Size: 0               Blocks: 0          IO Block: 4096   directory

Device: 15h/21d Inode: 1729821     Links: 6

Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)

Access: 2021-01-11 13:26:25.000047220 +0800

Modify: 2021-01-11 13:26:25.000047220 +0800

Change: 2021-01-11 13:26:25.000047220 +0800

Birth: -

 

For test container:

root@lava:/sys/devices/pci0000:00/0000:00:14.0/usb3/3-8# stat 3-8\:1.0

  File: 3-8:1.0

  Size: 0               Blocks: 0          IO Block: 4096   directory

Device: 79h/121d        Inode: 1729821     Links: 6

Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)

Access: 2021-01-11 13:26:48.564047334 +0000

Modify: 2021-01-11 13:26:48.564047334 +0000

Change: 2021-01-11 13:26:48.564047334 +0000

Birth: -

 

There are 23 seconds gap there, but the MTP case:

https://cs.android.com/android/platform/superproject/+/master:test/vts-testcase/hal/usb/gadget/V1_0/host/src/com/android/tests/usbgadget/HalUsbGadgetV1_0HostTest.java;l=112;drc=master?q=%20com.android.tests.usbgadget.HalUsbGadgetV1_0HostTes

Just sleep 3 seconds after svc usb setFunctions mtp true, that means there maybe time gap there that test_MTP case could find mtp device in /sys/devices.

 

Any suggestion for this? And still, could you share a job link how you run VTS MTP test case in docker test shell? Add @Milosz Wasilewski maybe.

 

From: Larry Shen
Sent: Friday, January 8, 2021 5:40 PM
To: lava-users@lists.lavasoftware.org
Subject: Ask android vts test link in docker test shell.

 

Hi, guys,

 

Recently we are running android VTS test in lava docker test shell, but find all MTP cases fail.

 

It reports:

 

01-08 07:42:38 D/ModuleDefinition: Running module armeabi-v7a HalUsbGadgetV1_0HostTest

01-08 07:42:43 I/ModuleListener: [1/5] com.android.tests.usbgadget.HalUsbGadgetV1_0HostTest#testMtp FAILURE: java.lang.AssertionError: MTP not present

    at org.junit.Assert.fail(Assert.java:88)

    at org.junit.Assert.assertTrue(Assert.java:41)

    at com.android.tests.usbgadget.HalUsbGadgetV1_0HostTest.testMtp(HalUsbGadgetV1_0HostTest.java:113)

 

Im a little lost currently, so before I have a deep investigation, I want to know if you can share a link about this case:

com.android.tests.usbgadget.HalUsbGadgetV1_0HostTest#testMtp

 

I know you guys run android tests on other product always, could share a link for us to reference? Or with good luck you know whats the potential root cause for my failure?

 

Thanks.