2016-07-04 19:04:41 +02:00
|
|
|
/*
|
|
|
|
* \brief Block session testing - ping pong test
|
|
|
|
* \author Josef Soentgen
|
|
|
|
* \date 2016-07-04
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2016-2018 Genode Labs GmbH
|
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
|
|
* under the terms of the GNU General Public License version 2.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _TEST_SEQUENTIAL_H_
|
|
|
|
#define _TEST_SEQUENTIAL_H_
|
|
|
|
|
2019-04-11 21:36:28 +02:00
|
|
|
namespace Test { struct Sequential; }
|
2016-07-04 19:04:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sequential operation test
|
|
|
|
*
|
|
|
|
* This test reads or writes the given number of blocks from the
|
|
|
|
* specified start block sequentially in sized requests.
|
|
|
|
*/
|
|
|
|
struct Test::Sequential : Test_base
|
|
|
|
{
|
2019-04-11 21:36:28 +02:00
|
|
|
block_number_t _start = _node.attribute_value("start", 0u);
|
|
|
|
size_t const _size = _node.attribute_value("size", Number_of_bytes());
|
|
|
|
size_t const _length = _node.attribute_value("length", Number_of_bytes());
|
2016-07-04 19:04:41 +02:00
|
|
|
|
2019-04-11 21:36:28 +02:00
|
|
|
Block::Operation::Type const _op_type = _node.attribute_value("write", false)
|
|
|
|
? Block::Operation::Type::WRITE
|
|
|
|
: Block::Operation::Type::READ;
|
2016-07-04 19:04:41 +02:00
|
|
|
|
2019-04-11 21:36:28 +02:00
|
|
|
using Test_base::Test_base;
|
2016-07-04 19:04:41 +02:00
|
|
|
|
2019-04-11 21:36:28 +02:00
|
|
|
void _init() override
|
2016-07-04 19:04:41 +02:00
|
|
|
{
|
2019-07-23 17:43:18 +02:00
|
|
|
if (_size > _scratch_buffer.size) {
|
2019-04-11 21:36:28 +02:00
|
|
|
error("request size exceeds scratch buffer size");
|
2016-07-04 19:04:41 +02:00
|
|
|
throw Constructing_test_failed();
|
|
|
|
}
|
|
|
|
|
2019-04-03 16:05:10 +02:00
|
|
|
if (_info.block_size > _size || (_size % _info.block_size) != 0) {
|
2019-04-11 21:36:28 +02:00
|
|
|
error("request size invalid");
|
2016-07-04 19:04:41 +02:00
|
|
|
throw Constructing_test_failed();
|
|
|
|
}
|
|
|
|
|
2019-04-03 16:05:10 +02:00
|
|
|
_size_in_blocks = _size / _info.block_size;
|
|
|
|
_length_in_blocks = _length / _info.block_size;
|
2019-04-11 21:36:28 +02:00
|
|
|
}
|
2016-07-04 19:04:41 +02:00
|
|
|
|
2019-04-11 21:36:28 +02:00
|
|
|
void _spawn_job() override
|
|
|
|
{
|
|
|
|
if (_bytes >= _length)
|
|
|
|
return;
|
2016-07-04 19:04:41 +02:00
|
|
|
|
2019-04-11 21:36:28 +02:00
|
|
|
_job_cnt++;
|
|
|
|
|
|
|
|
Block::Operation const operation { .type = _op_type,
|
|
|
|
.block_number = _start,
|
|
|
|
.count = _size_in_blocks };
|
|
|
|
|
|
|
|
new (_alloc) Job(*_block, operation, _job_cnt);
|
2016-07-04 19:04:41 +02:00
|
|
|
|
2019-04-11 21:36:28 +02:00
|
|
|
_start += _size_in_blocks;
|
2016-07-04 19:04:41 +02:00
|
|
|
}
|
|
|
|
|
2019-04-11 21:36:28 +02:00
|
|
|
Result result() override
|
2016-07-04 19:04:41 +02:00
|
|
|
{
|
|
|
|
return Result(_success, _end_time - _start_time,
|
2019-04-11 21:36:28 +02:00
|
|
|
_bytes, _rx, _tx, _size, _info.block_size, _triggered);
|
2016-07-04 19:04:41 +02:00
|
|
|
}
|
|
|
|
|
2019-02-14 22:39:08 +01:00
|
|
|
char const *name() const override { return "sequential"; }
|
2019-04-11 21:36:28 +02:00
|
|
|
|
|
|
|
void print(Genode::Output &out) const override
|
|
|
|
{
|
|
|
|
Genode::print(out, name(), " ", Block::Operation::type_name(_op_type), " "
|
|
|
|
"start:", _start, " "
|
|
|
|
"size:", _size, " "
|
|
|
|
"length:", _length, " "
|
|
|
|
"copy:", _copy, " "
|
|
|
|
"batch:", _batch);
|
|
|
|
}
|
2016-07-04 19:04:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _TEST_SEQUENTIAL_H_ */
|