mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
1.9 KiB
C++
82 lines
1.9 KiB
C++
6 years ago
|
/*
|
||
5 years ago
|
* Copyright 2013-2020 Software Radio Systems Limited
|
||
8 years ago
|
*
|
||
6 years ago
|
* This file is part of srsLTE.
|
||
8 years ago
|
*
|
||
6 years ago
|
* srsLTE is free software: you can redistribute it and/or modify
|
||
8 years ago
|
* it under the terms of the GNU Affero General Public License as
|
||
|
* published by the Free Software Foundation, either version 3 of
|
||
|
* the License, or (at your option) any later version.
|
||
|
*
|
||
6 years ago
|
* srsLTE is distributed in the hope that it will be useful,
|
||
8 years ago
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Affero General Public License for more details.
|
||
|
*
|
||
|
* A copy of the GNU Affero General Public License can be found in
|
||
|
* the LICENSE file in the top-level directory of this distribution
|
||
|
* and at http://www.gnu.org/licenses/.
|
||
|
*
|
||
|
*/
|
||
|
|
||
5 years ago
|
#define NMSGS 1000000
|
||
8 years ago
|
|
||
6 years ago
|
#include "srslte/common/buffer_pool.h"
|
||
5 years ago
|
#include "srslte/upper/byte_buffer_queue.h"
|
||
6 years ago
|
#include <stdio.h>
|
||
8 years ago
|
|
||
|
using namespace srslte;
|
||
|
|
||
|
typedef struct {
|
||
5 years ago
|
byte_buffer_queue* q;
|
||
5 years ago
|
} args_t;
|
||
8 years ago
|
|
||
5 years ago
|
void* write_thread(void* a)
|
||
|
{
|
||
|
args_t* args = (args_t*)a;
|
||
6 years ago
|
byte_buffer_pool* pool = byte_buffer_pool::get_instance();
|
||
5 years ago
|
for (uint32_t i = 0; i < NMSGS; i++) {
|
||
6 years ago
|
unique_byte_buffer_t b = srslte::allocate_unique_buffer(*pool, true);
|
||
8 years ago
|
memcpy(b->msg, &i, 4);
|
||
|
b->N_bytes = 4;
|
||
6 years ago
|
args->q->write(std::move(b));
|
||
8 years ago
|
}
|
||
|
return NULL;
|
||
|
}
|
||
|
|
||
5 years ago
|
int main(int argc, char** argv)
|
||
|
{
|
||
8 years ago
|
bool result;
|
||
5 years ago
|
byte_buffer_queue q;
|
||
6 years ago
|
unique_byte_buffer_t b;
|
||
8 years ago
|
pthread_t thread;
|
||
|
args_t args;
|
||
|
u_int32_t r;
|
||
|
|
||
|
result = true;
|
||
7 years ago
|
args.q = &q;
|
||
8 years ago
|
|
||
|
pthread_create(&thread, NULL, &write_thread, &args);
|
||
|
|
||
5 years ago
|
for (uint32_t i = 0; i < NMSGS; i++) {
|
||
6 years ago
|
b = q.read();
|
||
8 years ago
|
memcpy(&r, b->msg, 4);
|
||
5 years ago
|
if (r != i)
|
||
8 years ago
|
result = false;
|
||
|
}
|
||
|
|
||
|
pthread_join(thread, NULL);
|
||
|
|
||
7 years ago
|
if (q.size() != 0 || q.size_bytes() != 0) {
|
||
|
result = false;
|
||
|
}
|
||
|
|
||
5 years ago
|
if (result) {
|
||
8 years ago
|
printf("Passed\n");
|
||
|
exit(0);
|
||
5 years ago
|
} else {
|
||
8 years ago
|
printf("Failed\n;");
|
||
|
exit(1);
|
||
|
}
|
||
|
}
|