Skip to content

Usb msd tests #9444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 21, 2019
Merged

Usb msd tests #9444

merged 2 commits into from
Mar 21, 2019

Conversation

maciejbocianski
Copy link
Contributor

@maciejbocianski maciejbocianski commented Jan 21, 2019

Description

Test for USB MSD calss
Tested on Windows and Linux. On Mac should also work
Supported targets see TESTS/usb_device/msd/mbed_app.json
Targets with small RAM (less then 70kB) and without flash memory (e.g ARCH_PRO) require ci-sheild + SD card to enable testing

TODO:

  • update README.md

Known issues:

  • sometimes fs get corrupted while mounting on Windows machine
  • sometimes test hungs due to that greentea_parse_kv is preempted by usb msd communication task (it doesn't get message from host despite is was send and is visible on serial console)

Pull request type

[ ] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[X] Test update
[ ] Breaking change

Reviewers

@c1728p9

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 21, 2019

Please review astyle travis job

@ciarmcom ciarmcom requested review from c1728p9 and a team January 21, 2019 16:00
@ciarmcom
Copy link
Member

@maciejbocianski, thank you for your changes.
@c1728p9 @ARMmbed/mbed-os-maintainers please review.

@maciejbocianski
Copy link
Contributor Author

astyle fixed

@@ -0,0 +1,242 @@
"""
mbed SDK
Copy link
Contributor

@0xc0170 0xc0170 Jan 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use updated license header

/*
 * Copyright (c) 2019, Arm Limited and affiliates.
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

license headers fixed

Copy link
Contributor

@c1728p9 c1728p9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great so far. I left some minor feedback. Once the stability problems you mentioned above are fixed then this will be ready to go.

@@ -0,0 +1,39 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per-tests configs aren't allowed. You may be able to use the test configs at https://github.com/ARMmbed/mbed-os/tree/master/tools/test_configs. @bridadan or @theotherjimmy may have more details around this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately that mechanism isn't really documented. It seems like you can add an entry to the "default_test_configuration" but I haven't used it personally.

Copy link
Contributor Author

@maciejbocianski maciejbocianski Jan 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about --test-config <TEST_CONFIG> ?
It uses configs from https://github.com/ARMmbed/mbed-os/tree/master/tools/test_configs?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe so yes. If you don't specify a --test-config or an --app-config it seems to go with the default one.

#define MIN_HEAP_SIZE (HEAP_BLOCK_DEVICE_SIZE + 6144)


/* TODO:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you want to take action on this TODO?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, as soon as it will be supported in USBMSD class

"target.features_add": ["STORAGE"]
},
"K64F": {
"target.components_remove": ["SD"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does SD need to be removed from the K64F?

Copy link
Contributor Author

@maciejbocianski maciejbocianski Jan 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My assumption was to test embedded flash BD in the first place. In case of k64f it has components SD and FLASHAPI

"components_add": ["SD", "FLASHIAP"],

Because the BlockDevice::get_default_instance() implementation uses SD before FLASHAPI
(see code below) we have to remove SD to let BlockDevice::get_default_instance() use FLASHAPI
MBED_WEAK BlockDevice *BlockDevice::get_default_instance()
{
#if COMPONENT_SPIF
static SPIFBlockDevice default_bd(
MBED_CONF_SPIF_DRIVER_SPI_MOSI,
MBED_CONF_SPIF_DRIVER_SPI_MISO,
MBED_CONF_SPIF_DRIVER_SPI_CLK,
MBED_CONF_SPIF_DRIVER_SPI_CS,
MBED_CONF_SPIF_DRIVER_SPI_FREQ
);
return &default_bd;
#elif COMPONENT_QSPIF
static QSPIFBlockDevice default_bd(
MBED_CONF_QSPIF_QSPI_IO0,
MBED_CONF_QSPIF_QSPI_IO1,
MBED_CONF_QSPIF_QSPI_IO2,
MBED_CONF_QSPIF_QSPI_IO3,
MBED_CONF_QSPIF_QSPI_SCK,
MBED_CONF_QSPIF_QSPI_CSN,
MBED_CONF_QSPIF_QSPI_POLARITY_MODE,
MBED_CONF_QSPIF_QSPI_FREQ
);
return &default_bd;
#elif COMPONENT_DATAFLASH
static DataFlashBlockDevice default_bd(
MBED_CONF_DATAFLASH_SPI_MOSI,
MBED_CONF_DATAFLASH_SPI_MISO,
MBED_CONF_DATAFLASH_SPI_CLK,
MBED_CONF_DATAFLASH_SPI_CS
);
return &default_bd;
#elif COMPONENT_SD
static SDBlockDevice default_bd(
MBED_CONF_SD_SPI_MOSI,
MBED_CONF_SD_SPI_MISO,
MBED_CONF_SD_SPI_CLK,
MBED_CONF_SD_SPI_CS
);
return &default_bd;
#elif COMPONENT_FLASHIAP
#if (MBED_CONF_FLASHIAP_BLOCK_DEVICE_SIZE == 0) && (MBED_CONF_FLASHIAP_BLOCK_DEVICE_BASE_ADDRESS == 0xFFFFFFFF)
size_t flash_size;
uint32_t start_address;
uint32_t bottom_address;
FlashIAP flash;
int ret = flash.init();
if (ret != 0) {
return 0;
}
//Find the start of first sector after text area
bottom_address = align_up(FLASHIAP_APP_ROM_END_ADDR, flash.get_sector_size(FLASHIAP_APP_ROM_END_ADDR));
start_address = flash.get_flash_start();
flash_size = flash.get_flash_size();
ret = flash.deinit();
static FlashIAPBlockDevice default_bd(bottom_address, start_address + flash_size - bottom_address);
#else
static FlashIAPBlockDevice default_bd;
#endif
return &default_bd;
#else
return NULL;
#endif
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it'd be possible to remove the dependency on the physical device all together? Could you use a HeapBlockDevice instead? https://github.com/ARMmbed/mbed-os/blob/master/features/storage/blockdevice/HeapBlockDevice.h

Copy link
Contributor Author

@maciejbocianski maciejbocianski Jan 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. I'm already using heap block device.
The idea was to test more than one type of block device. The other problem is that many devices has not enough RAM to create 64kB heap block device (it's min size to mount FAT32 fs on it)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was to test more than one type of block device

I get ya. Though I think the main thing you're trying to test is the USB stack's interaction with the FileSystem API, not the BlockDevice API, correct?

The other problem is that many devices has not enough RAM to create 64kB heap block device (it's min size to mount FAT32 fs on it)

Dang that's a pain. Crazy idea: maybe there's a way to simulate having a large block device? Especially if you don't actually have to store everything and just need to say the data moving. Almost like a streaming block device or something. (I may be going too far off topic now)

SPI_MISO = P0_8,
SPI_SCK = P0_7,
SPI_CS = P0_6,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this change be upstreamed into master directly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I will do

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to master #9482


It will be used to find new disks mounted during test.
"""
self.initial_disk_list = set(MSDUtils.disks())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how test would behave if we run multiple ones in same hosts parallel? test looks a bit problematic in ci where >>2 devices are connected in same host and devices appears and disappeared all the time.

Copy link
Contributor Author

@maciejbocianski maciejbocianski Jan 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In current version it will not work.
There is a plan to enhance host side msd device discovery/unmount mechanism similar as it's done in usb serial tests (https://github.com/ARMmbed/mbed-os/blob/feature-hal-spec-usb-device/TESTS/usb_device/serial distinguished by serial number)

Copy link
Contributor Author

@maciejbocianski maciejbocianski Feb 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jupe serial number based host side storage detection was added 275d124
Serial number is generated so each test instance will have different one

@c1728p9 c1728p9 force-pushed the feature-hal-spec-usb-device branch from 091b0e7 to e23e57d Compare January 29, 2019 18:42
@maciejbocianski maciejbocianski force-pushed the usb_msd_tests branch 2 times, most recently from 26628b4 to 90c443a Compare January 30, 2019 08:55
@cmonr cmonr dismissed c1728p9’s stale review January 30, 2019 22:22

Please re-review. Comments appear to be addressed

@NirSonnenschein
Copy link
Contributor

@jupe @bridadan @c1728p9 please re-review latest changes.

@bridadan
Copy link
Contributor

bridadan commented Feb 6, 2019

@NirSonnenschein I left some previous comments but I don't believe I need to approve this PR. Let me know if that's not the case, though.

@cmonr
Copy link
Contributor

cmonr commented Feb 25, 2019

CI was started a bit ago.

@mbed-ci
Copy link

mbed-ci commented Feb 25, 2019

Test run: FAILED

Summary: 1 of 12 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_greentea-test

@maciejbocianski
Copy link
Contributor Author

features-storage-tests-blockdevice-general_block_device failed:

[1551119791.78][CONN][INF] found KV pair in stream: {{__testcase_name;Testing get type functionality}}, queued... 
[1551119791.88][CONN][RXD] >>> Running case #1: 'Testing BlockDevice erase functionality'... [1551119791.88][CONN][RXD] [1551119791.88][CONN][INF] found KV pair in stream: {{__testcase_start;Testing BlockDevice erase functionality}}, queued... 
[1551119791.98][CONN][RXD] Test BlockDevice::get_erase_value().. 
[1551119841.99][CONN][RXD] :229::FAIL: Expected 0 Was -5005 
[1551119841.99][CONN][RXD] block_device->get_erase_value()=-1 
[1551119842.19][CONN][RXD] :234::SKIP: Erase not supported in this block device. Test skipped. [1551119842.19][CONN][INF] found KV pair in stream: {{__testcase_finish;Testing BlockDevice erase functionality;0;1}}, queued... 
[1551119842.29][CONN][RXD] >>> 'Testing BlockDevice erase functionality': 0 passed, 1 failed with reason 'Test Cases Failed'

@cmonr
Copy link
Contributor

cmonr commented Mar 19, 2019

CI restarted

@mbed-ci
Copy link

mbed-ci commented Mar 19, 2019

Test run: SUCCESS

Summary: 13 of 13 test jobs passed
Build number : 2
Build artifacts

@cmonr
Copy link
Contributor

cmonr commented Mar 19, 2019

One moment, doing a thing.

@cmonr cmonr closed this Mar 19, 2019
@cmonr cmonr removed the needs: CI label Mar 19, 2019
@cmonr cmonr reopened this Mar 19, 2019
@cmonr
Copy link
Contributor

cmonr commented Mar 19, 2019

continuous-integration/travis-ci/pr Pending — The Travis CI build is in progres

Now we're cooking! 😁

@NirSonnenschein
Copy link
Contributor

Starting CI

@mbed-ci
Copy link

mbed-ci commented Mar 20, 2019

Test run: FAILED

Summary: 2 of 13 test jobs failed
Build number : 3
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_cloud-client-test
  • jenkins-ci/mbed-os-ci_exporter

@cmonr
Copy link
Contributor

cmonr commented Mar 20, 2019

CI job restarted: jenkins-ci/exporter

armclang: error: Failed to check out a license.

@cmonr
Copy link
Contributor

cmonr commented Mar 20, 2019

CI job restarted: jenkins-ci/cloud-client-test

WebSocketProtocolException: rsv is not implemented, yet

@0xc0170 0xc0170 merged commit f99431f into ARMmbed:master Mar 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants