Skip to content
Snippets Groups Projects
Commit 8f926691 authored by Yalu Zhang's avatar Yalu Zhang
Browse files

Merge from branch documentation and suppress multiple commitment into one

Add functional API test JSON files for the following objects
    - FAST
    - ATM
    - PTM
Also update DSL by adding configure mthodAdd functional API test JSON files for the following objects

Add JSON schemas to the output of the following ubus calls
    - fast.line status and stats
    - atm.link status and stats
    - ptm.line status

Add and update documents for newly added functions
    - DSL configure
    - ATM
    - PTM
    - FAST

Add unit-test cases for the configuration if DSL and ATM

Both positive and negative cases are included

Add UBUS objects for the configuration of DSL and ATM

Add UBUS objects for the status and statistics of ATM and PTM links

Add UBUS objects fast.line.x
parent 473a9537
No related branches found
No related tags found
No related merge requests found
Showing
with 2210 additions and 38 deletions
...@@ -65,15 +65,25 @@ config ptm-device 'ptm0' ...@@ -65,15 +65,25 @@ config ptm-device 'ptm0'
This is a verbose print of all methods published to ubus on a device. This is a verbose print of all methods published to ubus on a device.
```bash ```bash
'dsl' @d35e2f41 'atm.link.0' @607d41d6
"status":{} "status":{}
"stats":{} "stats":{}
'dsl.channel.0' @9f3ca1b2 "configure":{"link_type":"String","vpi":"Integer","vci":"Integer","encapsulation":"String","qos_class":"String","peak_cell_rate":"Integer","max_burst_size":"Integer","sustainable_cell_rate":"Integer"}
"status":{} 'dsl' @8e73ca86
"stats":{"interval":"String"} "status":{}
'dsl.line.0' @c01eec72 "stats":{}
"status":{} 'dsl.channel.0' @e76e0883
"stats":{"interval":"String"} "status":{}
"stats":{"interval":"String"}
'dsl.line.0' @3a06e2d2
"status":{}
"stats":{"interval":"String"}
"configure":{"xtse":"String","vdsl2_profiles":"String","fast_profiles":"String","data_gathering":"Boolean","limit_mask":"Integer","us0_mask":"Integer"}
'fast.line.0' @bc51c0a7
"status":{}
"stats":{"interval":"String"}
'ptm.link.0' @35822197
"status":{}
``` ```
For more info on the Ubus API see [link](./docs/ubus.splash.md) For more info on the Ubus API see [link](./docs/ubus.splash.md)
......
# atm.link.<number>
| List of Methods |
| --- |
| [status](#status) |
| [stats](#stats) |
| [configure](#configure) |
## status
`status`
Type: `Method`
### Ubus CLI Example
```bash
ubus call atm.link.0 status
```
### JSONRPC Example
```json
{
"jsonrpc": "2.0",
"id": 0,
"method": "call",
"params": ["<SID>", "atm.link.0", "status"]
}
```
### Input
None
### Output
- type: `object`
- Example as below
```json
{
"status": "up",
"link_type": "eoa",
"auto_config": true,
"dest_addr": {
"vpi": 8,
"vci": 35
},
"encapsulation": "llc",
"fcs_preserved": true,
"vc_search_list": [
{
"vpi": 8,
"vci": 36
},
{
"vpi": 8,
"vci": 37
}
],
"aal": "aal5",
"qos": {
"qos_class": "ubr",
"peak_cell_rate": 18867,
"max_burst_size": 22640,
"sustainable_cell_rate": 15093
}
}
```
## stats
`stats`
Type: `Method`
### Ubus CLI Example
```bash
ubus call atm.link.0 stats
```
### JSONRPC Example
```json
{
"jsonrpc": "2.0",
"id": 0,
"method": "call",
"params": ["<SID>", "atm.link.0", "stats"]
}
```
### Input
None
### Output
- type: `object`
- Example as below
```json
{
"transmitted_blocks": 12345678,
"received_blocks": 87654321,
"crc_errors": 12
}
```
## configure
`configure {...}`
Type: `Method`
### Ubus CLI Example
```bash
ubus call atm.link.0 configure "{'link_type':'eoa','vpi':8,'vci':35,'encapsulation':'llc',\
'qos_class':'ubr','peak_cell_rate':10240,'max_burst_size':8124,'sustainable_cell_rate':9600}"
```
### JSONRPC Example
```json
{
"jsonrpc": "2.0",
"id": 0,
"method": "call",
"params": ["<SID>", "atm.link.0", "configure", "{'link_type':'eoa','vpi':8,'vci':35,'encapsulation':'llc'}"]
}
```
### Input
- Type: `object`
- Parameter: `link_type`
- Value: ATM link type with one of values "eoa", "ipoa", "pppoa" and "cip"
- Parameer:`vpi`
- Value: unsigned int as virtual path index
- Parameer:`vci`
- Value: unsigned int as virtual circuit index
- Parameer:`encapsulation`
- Value: ATM link encapsulation with one of values "llc" and "vcmux"
- Parameer:`qos_class`
- Value: ATM QoS class with one of values "ubr", "cbr", "gfr", "vbr_nrt", "vbr_rt", "ubr_plus" and "abr"
- Parameer:`peak_cell_rate`
- Value: unsigned integer
- Parameer:`max_burst_size`
- Value: unsigned integer
- Parameer:`sustainable_cell_rate`
- Value: unsigned integer
### Output
None
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
| [status](#status) | | [status](#status) |
| [stats](#stats) | | [stats](#stats) |
| [stats_interval](#stats_interval) | | [stats_interval](#stats_interval) |
| [configure](#configure) |
## status ## status
...@@ -247,3 +248,50 @@ ubus call dsl.line.0 stats "{ 'interval': 'total'}" ...@@ -247,3 +248,50 @@ ubus call dsl.line.0 stats "{ 'interval': 'total'}"
"severely_errored_secs": 0 "severely_errored_secs": 0
} }
``` ```
## configure
`configure {...}`
Type: `Method`
### Ubus CLI Example
```bash
ubus call dsl.line.0 configure "{'xtse':'01,02,ab,cd,41,52,f8,6e',\
'vdsl2_profiles':'8a,8b,8c,8d,17a,30a,35b',\
'fast_profiles':'106a,212a','data_gathering':true,'limit_mask':255,'us0_mask':511}"
```
### JSONRPC Example
```json
{
"jsonrpc": "2.0",
"id": 0,
"method": "call",
"params": ["<SID>", "dsl.line.0", "configure", "{'xtse':'01,02,ab,cd,41,52,f8,6e','vdsl2_profiles':'8a,8b,8c,8d,17a,30a,35b'}"]
}
```
### Input
- Type: `object`
- Parameter: `xtse`
- Value: 8 octects which include all modes supported by the DSL line
- Parameer:`vdsl2_profiles`
- Value: Sub/full set of "8a,8b,8c,8d,17a,30a,35b" of VDSL2 profiles
- Parameer:`fast_profiles`
- Value: Sub/full set of "106a,212a" of FAST profiles
- Parameer:`data_gathering`
- Value: true or false to enale/disable data gathering
- Parameer:`limit_mask`
- Value: unsigned integer as limit mask
- Parameer:`us0_mask`
- Value: unsigned integer as us0 mask
### Output
None
# fast.line.&lt;number&gt;
| List of Methods |
| --- |
| [status](#status) |
| [stats](#stats) |
| [stats_interval](#stats_interval) |
## status
`status`
Type: `Method`
### Ubus CLI Example
```bash
ubus call fast.line.0 status
```
### JSONRPC Example
```json
{
"jsonrpc": "2.0",
"id": 0,
"method": "call",
"params": ["<SID>", "fast.line.0", "status"]
}
```
### Input
None
### Output
- type: `object`
- Example as below
```json
{
"status": "up",
"upstream": true,
"firmware_version": "A2pvfbH045k.d28a",
"link_status": "up",
"current_profile": "106a",
"power_management_state": "l0",
"max_bit_rate": {
"us": 201000,
"ds": 402000
},
"allowed_profiles": [
"106a",
"212a"
],
"success_failure_cause": 0,
"upbokler": 180,
"last_transmitted_signal": {
"us": 100,
"ds": 200
},
"upbokle": 160,
"line_number": 1,
"noise_margin": {
"us": 146,
"ds": 177
},
"attenuation": {
"us": 0,
"ds": 48
},
"power": {
"us": 123,
"ds": 106
},
"snrm_rmc": {
"us": 12,
"ds": 14
},
"bits_rmc_ps": [
1,
3,
5,
7
],
"fext_to_cancel_enable": {
"us": true,
"ds": true
},
"etr": {
"us": 250000,
"ds": 350000
},
"att_etr": {
"us": 225000,
"ds": 325000
},
"min_eftr": {
"us": 200000,
"ds": 300000
}
}
```
## stats
`stats`
Type: `Method`
### Ubus CLI Example
```bash
ubus call fast.line.0 stats
```
### JSONRPC Example
```json
{
"jsonrpc": "2.0",
"id": 0,
"method": "call",
"params": ["<SID>", "fast.line.0", "stats"]
}
```
### Input
None
### Output
- type: `object`
- Example as below
```json
{
"total_start": 397,
"showtime_start": 349,
"last_showtime_start": 349,
"current_day_start": 397,
"quarter_hour_start": 397,
"total": {
"errored_secs": 20,
"severely_errored_secs": 5,
"loss": 1,
"lors": 4294967295,
"uas": 1,
"rtx_uc": 4294967295,
"rtx_tx": 0,
"success_bsw": 1024,
"success_sra": 2048,
"success_fra": 1024,
"success_rpa": 2048,
"success_tiga": 1024
},
"showtime": {
"errored_secs": 20,
"severely_errored_secs": 5,
"loss": 1,
"lors": 4294967295,
"uas": 1,
"rtx_uc": 4294967295,
"rtx_tx": 0,
"success_bsw": 1024,
"success_sra": 2048,
"success_fra": 1024,
"success_rpa": 2048,
"success_tiga": 1024
},
"lastshowtime": {
"errored_secs": 20,
"severely_errored_secs": 5,
"loss": 1,
"lors": 4294967295,
"uas": 1,
"rtx_uc": 4294967295,
"rtx_tx": 0,
"success_bsw": 1024,
"success_sra": 2048,
"success_fra": 1024,
"success_rpa": 2048,
"success_tiga": 1024
},
"currentday": {
"errored_secs": 20,
"severely_errored_secs": 5,
"loss": 1,
"lors": 4294967295,
"uas": 1,
"rtx_uc": 4294967295,
"rtx_tx": 0,
"success_bsw": 1024,
"success_sra": 2048,
"success_fra": 1024,
"success_rpa": 2048,
"success_tiga": 1024
},
"quarterhour": {
"errored_secs": 20,
"severely_errored_secs": 5,
"loss": 1,
"lors": 4294967295,
"uas": 1,
"rtx_uc": 4294967295,
"rtx_tx": 0,
"success_bsw": 1024,
"success_sra": 2048,
"success_fra": 1024,
"success_rpa": 2048,
"success_tiga": 1024
}
}
```
## stats_interval
`stats <interval>`
Type: `Method`
### Ubus CLI Example
```bash
ubus call fast.line.0 stats "{ 'interval': 'total'}"
```
### JSONRPC Example
```json
{
"jsonrpc": "2.0",
"id": 0,
"method": "call",
"params": ["<SID>", "fast.line.0", "stats", "{ 'interval': 'total'}"]
}
```
### Input
- Type: `object`
- Parameter: `interval`
- Value: `total`, `showtime`, `lastshowtime`, `currentday`, or `quarterhour`
### Output
- type: `object`
- Example as below
```json
{
"errored_secs": 20,
"severely_errored_secs": 5,
"loss": 1,
"lors": 4294967295,
"uas": 1,
"rtx_uc": 4294967295,
"rtx_tx": 0,
"success_bsw": 1024,
"success_sra": 2048,
"success_fra": 1024,
"success_rpa": 2048,
"success_tiga": 1024
}
```
# ptm.link.&lt;number&gt;
| List of Methods |
| --- |
| [status](#status) |
## status
`status`
Type: `Method`
### Ubus CLI Example
```bash
ubus call ptm.link.0 status
```
### JSONRPC Example
```json
{
"jsonrpc": "2.0",
"id": 0,
"method": "call",
"params": ["<SID>", "ptm.link.0", "status"]
}
```
### Input
None
### Output
- type: `object`
- Example as below
```json
{
"status": "up",
"mac_addr": "00:11:22:33:44:55"
}
```
...@@ -29,6 +29,7 @@ using JSON-C library APIs. ...@@ -29,6 +29,7 @@ using JSON-C library APIs.
| 1 | status | No argument | [1](./api/dsl.line.md#status) | | 1 | status | No argument | [1](./api/dsl.line.md#status) |
| 2 | stats | No argument | [2](./api/dsl.line.md#stats) | | 2 | stats | No argument | [2](./api/dsl.line.md#stats) |
| 3 | stats | Interval | [3](./api/dsl.line.md#stats_interval) | | 3 | stats | Interval | [3](./api/dsl.line.md#stats_interval) |
| 9 | configure | DSL_config | [9](./api/dsl.line.md#configure) |
#### dsl.channel.&lt;number&gt; #### dsl.channel.&lt;number&gt;
...@@ -45,6 +46,28 @@ using JSON-C library APIs. ...@@ -45,6 +46,28 @@ using JSON-C library APIs.
| 7 | status | No argument | [7](./api/dsl.md#status) | | 7 | status | No argument | [7](./api/dsl.md#status) |
| 8 | stats | No argument | [8](./api/dsl.md#stats) | | 8 | stats | No argument | [8](./api/dsl.md#stats) |
#### fast.line.&lt;number&gt;
| Execution ID | Method | Description | Function ID Coverage |
| :--- | :--- | :--- | :--- |
| 10 | status | No argument | [10](./api/fast.line.md#status) |
| 11 | stats | No argument | [11](./api/fast.line.md#stats) |
| 12 | stats | Interval | [12](./api/fast.line.md#stats_interval) |
#### atm.link.&lt;number&gt;
| Execution ID | Method | Description | Function ID Coverage |
| :--- | :--- | :--- | :--- |
| 13 | status | No argument | [13](./api/atm.link.md#status) |
| 14 | stats | No argument | [14](./api/atm.link.md#stats) |
| 15 | configure | ATM_config | [15](./api/atm.link.md#configure) |
#### ptm.link.&lt;number&gt;
| Execution ID | Method | Description | Function ID Coverage |
| :--- | :--- | :--- | :--- |
| 16 | status | No argument | [16](./api/ptm.link.md#status) |
### Unit Tests ### Unit Tests
The *dslmngr* unit tests are written in CMocka, invoking the UBUS callbacks directly from the source code, which is compiled The *dslmngr* unit tests are written in CMocka, invoking the UBUS callbacks directly from the source code, which is compiled
...@@ -53,16 +76,20 @@ into a shared library. This means mocking the arguments of a CLI or libubus invo ...@@ -53,16 +76,20 @@ into a shared library. This means mocking the arguments of a CLI or libubus invo
The output of the UBUS callbacks are retrieved by manipulation of the function ubus_send_reply(). Then the output is analyzed The output of the UBUS callbacks are retrieved by manipulation of the function ubus_send_reply(). Then the output is analyzed
and verified by each test case. and verified by each test case.
| Execution ID | Method | Test Case Name | Function ID Coverage | | Execution ID | Method | Test Case Name | Function ID Coverage |
| :--- | :--- | :--- | :--- | | :--- | :--- | :--- | :--- |
| 1 | line_status | test_api_dsl_line_status | [1](./api/dsl.line.md#status) | | 1 | line_status | test_api_dsl_line_status | [1](./api/dsl.line.md#status) |
| 2 | line_stats | test_api_dsl_line_stats | [2](./api/dsl.line.md#stats) | | 2 | line_stats | test_api_dsl_line_stats | [2](./api/dsl.line.md#stats) |
| 3 | line_stats_interval | test_api_dsl_line_stats_interval | [3](./api/dsl.line.md#stats_interval) | | 3 | line_stats_interval | test_api_dsl_line_stats_interval | [3](./api/dsl.line.md#stats_interval) |
| 4 | channel_status | test_api_dsl_channel_status | [4](./api/dsl.channel.md#status) | | 4 | channel_status | test_api_dsl_channel_status | [4](./api/dsl.channel.md#status) |
| 5 | channel_stats | test_api_dsl_channel_stats | [5](./api/dsl.channel.md#stats) | | 5 | channel_stats | test_api_dsl_channel_stats | [5](./api/dsl.channel.md#stats) |
| 6 | channel_stats_interval | test_api_dsl_channel_stats_interval | [6](./api/dsl.channel.md#stats_interval) | | 6 | channel_stats_interval | test_api_dsl_channel_stats_interval | [6](./api/dsl.channel.md#stats_interval) |
| 7 | dsl_status | test_api_dsl_status | [7](./api/dsl.md#status) | | 7 | dsl_status | test_api_dsl_status | [7](./api/dsl.md#status) |
| 8 | dsl_stats | test_api_dsl_stats | [8](./api/dsl.md#stats) | | 8 | dsl_stats | test_api_dsl_stats | [8](./api/dsl.md#stats) |
| 9 | dsl_configure | test_api_dsl_configure | [9](./api/dsl.line.md#configure) |
| 10 | dsl_configure_fail | test_api_dsl_configure_fail | [9](./api/dsl.line.md#configure) |
| 11 | atm_configure | test_api_atm_configure | [15](./api/atm.link.md#configure) |
| 12 | atm_configure_fail | test_api_atm_configure_fai | [15](./api/atm.link.md#configure) |
#### test_api_dsl_line_status #### test_api_dsl_line_status
...@@ -191,3 +218,72 @@ Test the *dslmngr* UBUS API callback `dsl_stats_all()`, providing the method [ds ...@@ -191,3 +218,72 @@ Test the *dslmngr* UBUS API callback `dsl_stats_all()`, providing the method [ds
Parameters' values included in the returned JSON object of the output shall be equal to those returned by the corresponding Parameters' values included in the returned JSON object of the output shall be equal to those returned by the corresponding
stub API in *libdsl* building for TEST platform. stub API in *libdsl* building for TEST platform.
#### dsl_configure
##### Description
Test the *dslmngr* UBUS API callback `dsl_line_configure()`, providing the method [dsl configure](./api/dsl.line.md#configure).
##### Test Steps
- Prepare valid input parameters
- Call `dsl_line_configure()`
- Analyze and verify the output
##### Expected Results
The dumped input parameters by the corresponding libdsl API must be as same as those prepared in th first step. And the
returned value must indicate success.
#### dsl_configure_fail
##### Description
Test the *dslmngr* UBUS API callback `dsl_line_configure()`, providing the method [dsl configure](./api/dsl.line.md#configure).
##### Test Steps
- Prepare invalid input parameters
- Call `dsl_line_configure()`
- Analyze and verify the output
##### Expected Results
The dumped input parameters by the corresponding libdsl API must be as same as those prepared in th first step. And the
returned value must indicate failure.
#### atm_configure
##### Description
Test the *dslmngr* UBUS API callback `atm_link_configure()`, providing the method [atm configure](./api/atm.link.md#configure).
##### Test Steps
- Prepare valid input parameters
- Call `atm_link_configure()`
- Analyze and verify the output
##### Expected Results
The dumped input parameters by the corresponding libdsl API must be as same as those prepared in th first step. And the
returned value must indicate success.
#### atm_configure_fail
##### Description
Test the *dslmngr* UBUS API callback `atm_link_configure()`, providing the method [atm configure](./api/atm.link.md#configure).
##### Test Steps
- Prepare valid input parameters
- Call `atm_link_configure()`
- Analyze and verify the output
##### Expected Results
The dumped input parameters by the corresponding libdsl API must be as same as those prepared in th first step. And the
returned value must indicate failure.
...@@ -3,3 +3,6 @@ ...@@ -3,3 +3,6 @@
* [DSL](./api/dsl.md) * [DSL](./api/dsl.md)
* [DSL Line](./api/dsl.line.md) * [DSL Line](./api/dsl.line.md)
* [DSL Channel](./api/dsl.channel.md) * [DSL Channel](./api/dsl.channel.md)
* [FAST Line](./api/fast.line.md)
* [ATM Link](./api/atm.link.md)
* [PTM Link](./api/ptm.link.md)
This diff is collapsed.
...@@ -31,7 +31,12 @@ extern "C" { ...@@ -31,7 +31,12 @@ extern "C" {
#include <syslog.h> #include <syslog.h>
#include <libubus.h> #include <libubus.h>
#define DSLMNGR_LOG(log_level, format...) fprintf(stderr, ##format) extern int current_log_level;
#define DSLMNGR_LOG(log_level, format...) do { \
if (log_level <= current_log_level) \
fprintf(stderr, ##format); \
} while(0)
#define CHECK_POINT() printf("Check point at %s@%s:%d\n", __func__, __FILE__, __LINE__) #define CHECK_POINT() printf("Check point at %s@%s:%d\n", __func__, __FILE__, __LINE__)
...@@ -50,6 +55,22 @@ int dsl_channel_stats(struct ubus_context *ctx, struct ubus_object *obj, ...@@ -50,6 +55,22 @@ int dsl_channel_stats(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method, struct blob_attr *msg); struct ubus_request_data *req, const char *method, struct blob_attr *msg);
int dsl_stats_all(struct ubus_context *ctx, struct ubus_object *obj, int dsl_stats_all(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method, struct blob_attr *msg); struct ubus_request_data *req, const char *method, struct blob_attr *msg);
int fast_line_status(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method, struct blob_attr *msg);
int fast_line_stats_handler(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method, struct blob_attr *msg);
int atm_link_status(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method, struct blob_attr *msg);
int atm_link_stats_handler(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method, struct blob_attr *msg);
int ptm_link_status(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method, struct blob_attr *msg);
int dsl_line_configure(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method, struct blob_attr *msg);
int atm_link_configure(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method, struct blob_attr *msg);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://www.iopsys.eu/atm.link_stats.json",
"title": "JSON Schema for the output of the UBUS call: atm.link.x stats",
"definitions": {
"stats_counter": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
"atm_link_stats": {
"$id": "#atm_link_stats",
"type": "object",
"properties" : {
"transmitted_blocks": { "$ref": "#/definitions/stats_counter" },
"received_blocks": { "$ref": "#/definitions/stats_counter" },
"crc_errors": { "$ref": "#/definitions/stats_counter" }
},
"required": [
"transmitted_blocks",
"received_blocks",
"crc_errors"
]
}
},
"$ref": "#atm_link_stats"
}
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://www.iopsys.eu/atm.link_status.json",
"title": "JSON Schema for the output of the UBUS call: atm.link.x status",
"definitions": {
"if_status": {
"type": "string",
"enum": [ "up", "down", "dormant", "not_present", "lower_layer_down", "error", "unknown" ]
},
"atm_link_type": {
"type": "string",
"enum": [ "unconfigured", "eoa", "ipoa", "pppoa", "cip", "unknown" ]
},
"destination": {
"type": "object",
"properties": {
"vpi": { "type": "integer" },
"vci": { "type": "integer" }
},
"required": [ "vpi", "vci" ]
},
"atm_link_status": {
"$id": "#atm_link_status",
"type": "object",
"properties" : {
"status": { "$ref": "#/definitions/if_status" },
"link_type": { "$ref": "#/definitions/atm_link_type" },
"auto_config": {"type": "boolean" },
"dest_addr": { "$ref": "#/definitions/destination" },
"encapsulation": {
"type": "string",
"enum": [ "llc", "vcmux" ]
},
"fcs_preserved": { "type": "boolean" },
"vc_search_list": {
"type": "array",
"minItems": 0,
"Items": { "$ref": "#/definitions/destination" }
},
"aal": {
"type": "string",
"enum": [ "aal1", "aal2", "aal3", "aal4", "aal5" ]
},
"qos": {
"type": "object",
"properties": {
"qos_class": {
"type": "string",
"enum": [ "ubr", "cbr", "gfr", "vbr_nrt", "vbr_rt", "ubr_plus", "abr" ]
},
"peak_cell_rate": { "$ref": "http://json-schema.org/draft-07/schema#/definitions/nonNegativeInteger" },
"max_burst_size": { "$ref": "http://json-schema.org/draft-07/schema#/definitions/nonNegativeInteger" },
"sustainable_cell_rate": { "$ref": "http://json-schema.org/draft-07/schema#/definitions/nonNegativeInteger" }
},
"required": [ "qos_class", "peak_cell_rate", "max_burst_size", "sustainable_cell_rate" ]
}
},
"required": [
"status",
"link_type",
"auto_config",
"dest_addr",
"encapsulation",
"fcs_preserved",
"vc_search_list",
"aal",
"qos"
]
}
},
"$ref": "#atm_link_status"
}
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://www.iopsys.eu/fast.line_stats.json",
"title": "JSON Schema for the output of the UBUS call: fast.line.x stats",
"definitions": {
"stats_counter": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
"line_stats_interval" : {
"$id": "#line_stats_interval",
"type": "object",
"properties": {
"errored_secs": { "$ref": "#/definitions/stats_counter" },
"severely_errored_secs": { "$ref": "#/definitions/stats_counter" },
"loss": { "$ref": "#/definitions/stats_counter" },
"lors": { "$ref": "#/definitions/stats_counter" },
"uas": { "$ref": "#/definitions/stats_counter" },
"rtx_uc": { "$ref": "#/definitions/stats_counter" },
"rtx_tx": { "$ref": "#/definitions/stats_counter" },
"success_bsw": { "$ref": "#/definitions/stats_counter" },
"success_sra": { "$ref": "#/definitions/stats_counter" },
"success_fra": { "$ref": "#/definitions/stats_counter" },
"success_rpa": { "$ref": "#/definitions/stats_counter" },
"success_tiga": { "$ref": "#/definitions/stats_counter" }
},
"required": [
"errored_secs",
"severely_errored_secs",
"loss",
"lors",
"uas",
"rtx_uc",
"rtx_tx",
"success_bsw",
"success_sra",
"success_fra",
"success_rpa",
"success_tiga"
]
},
"line_stats": {
"$id": "#line_stats",
"type": "object",
"properties" : {
"total_start": { "$ref": "http://json-schema.org/draft-07/schema#/definitions/nonNegativeInteger" },
"showtime_start": { "$ref": "http://json-schema.org/draft-07/schema#/definitions/nonNegativeInteger" },
"last_showtime_start": { "$ref": "http://json-schema.org/draft-07/schema#/definitions/nonNegativeInteger" },
"current_day_start": { "$ref": "http://json-schema.org/draft-07/schema#/definitions/nonNegativeInteger" },
"quarter_hour_start": { "$ref": "http://json-schema.org/draft-07/schema#/definitions/nonNegativeInteger" },
"total": { "$ref": "#line_stats_interval" },
"showtime": { "$ref": "#line_stats_interval" },
"lastshowtime": { "$ref": "#line_stats_interval" },
"currentday": { "$ref": "#line_stats_interval" },
"quarterhour": { "$ref": "#line_stats_interval" }
},
"required": [
"total_start",
"showtime_start",
"last_showtime_start",
"current_day_start",
"quarter_hour_start",
"total",
"showtime",
"lastshowtime",
"currentday",
"quarterhour"
]
}
},
"$ref": "#line_stats"
}
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://www.iopsys.eu/fast.line_stats_interval.json",
"title": "JSON Schema for the output of the UBUS call: fast.line.x stats <interval>",
"definitions": {
"stats_counter": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295
},
"line_stats_interval" : {
"$id": "#line_stats_interval",
"type": "object",
"properties": {
"errored_secs": { "$ref": "#/definitions/stats_counter" },
"severely_errored_secs": { "$ref": "#/definitions/stats_counter" },
"loss": { "$ref": "#/definitions/stats_counter" },
"lors": { "$ref": "#/definitions/stats_counter" },
"uas": { "$ref": "#/definitions/stats_counter" },
"rtx_uc": { "$ref": "#/definitions/stats_counter" },
"rtx_tx": { "$ref": "#/definitions/stats_counter" },
"success_bsw": { "$ref": "#/definitions/stats_counter" },
"success_sra": { "$ref": "#/definitions/stats_counter" },
"success_fra": { "$ref": "#/definitions/stats_counter" },
"success_rpa": { "$ref": "#/definitions/stats_counter" },
"success_tiga": { "$ref": "#/definitions/stats_counter" }
},
"required": [
"errored_secs",
"severely_errored_secs",
"loss",
"lors",
"uas",
"rtx_uc",
"rtx_tx",
"success_bsw",
"success_sra",
"success_fra",
"success_rpa",
"success_tiga"
]
}
},
"$ref": "#line_stats_interval"
}
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://www.iopsys.eu/fast.line_status.json",
"title": "JSON Schema for the output of the UBUS call: fast.line.x status",
"definitions": {
"if_status": {
"type": "string",
"enum": [ "up", "down", "dormant", "not_present", "lower_layer_down", "error", "unknown" ]
},
"link_status": {
"type": "string",
"enum": [ "up", "initializing", "establishing", "no_signal", "disabled", "error", "unknown" ]
},
"fast_profile": {
"type": "string",
"enum": [ "106a", "212a", "unknown" ]
},
"power_mgmt_state": {
"type": "string",
"enum": [ "l0", "l2_1", "l2_2", "l3", "unknown" ]
},
"integer_array": {
"type": "array",
"items": { "type": "integer" },
"minItems": 0
},
"bidirectional_integers": {
"type": "object",
"properties": {
"us": { "type": "integer" },
"ds": { "type": "integer" }
},
"required": [ "us", "ds" ]
},
"bidirectional_bools": {
"type": "object",
"properties": {
"us": { "type": "boolean" },
"ds": { "type": "boolean" }
},
"required": [ "us", "ds" ]
},
"line_status": {
"$id": "#line_status",
"type": "object",
"properties" : {
"status": { "$ref": "#/definitions/if_status" },
"upstream": { "type": "boolean" },
"firmware_version": {"type": "string" },
"link_status": { "$ref": "#/definitions/link_status" },
"current_profile": { "$ref": "#/definitions/fast_profile" },
"power_management_state": { "$ref": "#/definitions/power_mgmt_state" },
"max_bit_rate": { "$ref": "#/definitions/bidirectional_integers" },
"allowed_profiles": {
"type": "array",
"items": { "$ref": "#/definitions/fast_profile" },
"minItems": 0
},
"success_failure_cause": { "type": "integer" },
"upbokler": { "type": "integer" },
"last_transmitted_signal": { "$ref": "#/definitions/bidirectional_integers" },
"upbokle": { "type": "integer" },
"line_number": { "type": "integer" },
"noise_margin": { "$ref": "#/definitions/bidirectional_integers" },
"last_state_transmitted": { "$ref": "#/definitions/bidirectional_integers" },
"attenuation": { "type": "integer" },
"trellis": { "$ref": "#/definitions/bidirectional_integers" },
"power": { "$ref": "#/definitions/bidirectional_integers" },
"snrm_rmc": { "$ref": "#/definitions/bidirectional_integers" },
"bits_rmc_ps": { "$ref": "#/definitions/integer_array" },
"attenuation": { "$ref": "#/definitions/bidirectional_integers" },
"fext_to_cancel_enable": { "$ref": "#/definitions/bidirectional_bools" },
"etr": { "$ref": "#/definitions/bidirectional_integers" },
"att_etr": { "$ref": "#/definitions/bidirectional_integers" },
"min_eftr": { "$ref": "#/definitions/bidirectional_integers" }
},
"required": [
"status",
"upstream",
"firmware_version",
"link_status",
"current_profile",
"power_management_state",
"max_bit_rate",
"allowed_profiles",
"success_failure_cause",
"upbokler",
"last_transmitted_signal",
"upbokle",
"line_number",
"noise_margin",
"attenuation",
"power",
"snrm_rmc",
"bits_rmc_ps",
"fext_to_cancel_enable",
"etr",
"att_etr",
"min_eftr"
]
}
},
"$ref": "#line_status"
}
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://www.iopsys.eu/ptm.link_status.json",
"title": "JSON Schema for the output of the UBUS call: ptm.link.x status",
"definitions": {
"if_status": {
"type": "string",
"enum": [ "up", "down", "dormant", "not_present", "lower_layer_down", "error", "unknown" ]
},
"mac_address": {
"type": "string",
"pattern": "[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}",
"minLength": 17,
"maxLength": 17
},
"ptm_link_status": {
"$id": "#ptm_link_status",
"type": "object",
"properties" : {
"status": { "$ref": "#/definitions/if_status" },
"mac_addr": { "$ref": "#/definitions/mac_address" }
},
"required": [
"status",
"mac_addr"
]
}
},
"$ref": "#ptm_link_status"
}
{
"object": "atm.link.0",
"methods": [
{
"method": "status",
"rc": 0
},
{
"method": "stats",
"rc": 0
},
{
"method": "configure",
"args": {
"link_type": "eoa",
"vpi": 8,
"vci": 35,
"encapsulation": "llc",
"qos_class": "ubr"
},
"rc": 0
}
]
}
ubus call atm.link.0 configure "{'link_type':'eoa','vpi':8,'vci':35,'encapsulation':'llc',\
'qos_class':'ubr','peak_cell_rate':10240,'max_burst_size':8124,'sustainable_cell_rate':9600}"
...@@ -51,5 +51,18 @@ ...@@ -51,5 +51,18 @@
}, },
"rc": 0 "rc": 0
}, },
{
"method": "configure",
"args": {
"xtse": "01,02,ab,cd,41,52,f8,6e",
"vdsl2_profiles": "8a,8b,8c,8d,17a,30a,35b",
"fast_profiles": "106a,212a",
"data_gathering": true,
"limit_mask": 7,
"us0_mask": 3
},
"rc": 0
}
] ]
} }
{
"object": "fast.line.0",
"methods": [
{
"method": "status",
"rc": 0
},
{
"method": "stats",
"rc": 0
},
{
"method": "stats",
"args": {
"interval": "total"
},
"rc": 0
},
{
"method": "stats",
"args": {
"interval": "showtime"
},
"rc": 0
},
{
"method": "stats",
"args": {
"interval": "lastshowtime"
},
"rc": 0
},
{
"method": "stats",
"args": {
"interval": "currentday"
},
"rc": 0
},
{
"method": "stats",
"args": {
"interval": "quarterhour"
},
"rc": 0
}
]
}
{
"object": "ptm.link.0",
"methods": [
{
"method": "status",
"rc": 0
}
]
}
...@@ -19,9 +19,15 @@ ...@@ -19,9 +19,15 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA * 02110-1301 USA
*/ */
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdarg.h> #include <stdarg.h>
#include <stddef.h> #include <stddef.h>
#include <setjmp.h> #include <setjmp.h>
#include <errno.h>
#include <cmocka.h> #include <cmocka.h>
#include <libubus.h> #include <libubus.h>
...@@ -36,11 +42,14 @@ ...@@ -36,11 +42,14 @@
#include "dslmngr.h" #include "dslmngr.h"
#include "utils.h" #include "utils.h"
#define LIBDSL_LOG_INPUT_PARAMS "/tmp/libdsl-input-params.log"
struct test_ctx { struct test_ctx {
struct blob_buf bb; struct blob_buf bb;
struct ubus_object dsl; struct ubus_object dsl;
struct ubus_object dsl_line; struct ubus_object dsl_line;
struct ubus_object dsl_channel; struct ubus_object dsl_channel;
struct ubus_object atm_link;
}; };
/* Overload ubus_send_reply to prevent segment fault*/ /* Overload ubus_send_reply to prevent segment fault*/
...@@ -66,6 +75,9 @@ static int setup(void **state) ...@@ -66,6 +75,9 @@ static int setup(void **state)
blob_buf_init(&ctx->bb, 0); blob_buf_init(&ctx->bb, 0);
// Delete the log file for libdsl input parameters dump
unlink(LIBDSL_LOG_INPUT_PARAMS);
return 0; return 0;
} }
...@@ -89,6 +101,7 @@ static int group_setup(void **state) ...@@ -89,6 +101,7 @@ static int group_setup(void **state)
ctx->dsl.name = "dsl"; ctx->dsl.name = "dsl";
ctx->dsl_line.name = "dsl.line.0"; ctx->dsl_line.name = "dsl.line.0";
ctx->dsl_channel.name = "dsl.channel.0"; ctx->dsl_channel.name = "dsl.channel.0";
ctx->atm_link.name = "atm.link.0";
memset(&ctx->bb, 0, sizeof(struct blob_buf)); memset(&ctx->bb, 0, sizeof(struct blob_buf));
*state = ctx; *state = ctx;
...@@ -223,6 +236,210 @@ static void test_api_dsl_stats(void **state) ...@@ -223,6 +236,210 @@ static void test_api_dsl_stats(void **state)
validate_dsl_stats(json_output); validate_dsl_stats(json_output);
} }
static struct json_object *get_json_obj_from_log()
{
int fd = -1;
char *str = NULL;
// Put the output of ubus call into a string
fd = open(LIBDSL_LOG_INPUT_PARAMS, O_RDONLY);
assert_return_code(fd, errno);
struct stat st;
int rc = fstat(fd, &st);
assert_true(rc == 0 && st.st_size > 0);
str = calloc(1, (size_t)st.st_size + 1);
assert_non_null(str);
ssize_t read_len = read(fd, str, (size_t)st.st_size);
assert_int_equal((int)read_len, (int)st.st_size);
// Parse the string to a json_object
char *start = strchr(str, '{');
assert_non_null(start);
//puts(start);
struct json_object *obj = json_tokener_parse(start);
if (fd >= 0)
close(fd);
if (str)
free(str);
return obj;
}
static void test_api_dsl_configure(void **state)
{
const char *xtse_val = "01,02,ab,cd,41,52,f8,6e";
const char *vdsl2_profiles_val = "8a,8b,8c,8d,17a,30a,35b";
const char *fast_profiles_val = "106a,212a";
const bool data_gathering_val = true;
const unsigned int limit_mask_val = 7;
const unsigned int us0_mask_val = 3;
struct test_ctx *ctx = (struct test_ctx *) *state;
struct blob_buf *bb = &ctx->bb;
struct ubus_object *obj = &ctx->dsl_line;
// Prepare the input parameters
blobmsg_add_string(bb, "xtse", xtse_val);
blobmsg_add_string(bb, "vdsl2_profiles", vdsl2_profiles_val);
blobmsg_add_string(bb, "fast_profiles", fast_profiles_val);
blobmsg_add_u8(bb, "data_gathering", data_gathering_val);
blobmsg_add_u32(bb, "limit_mask", limit_mask_val);
blobmsg_add_u32(bb, "us0_mask", us0_mask_val);
// Call the function to be tested
int res = dsl_line_configure(NULL, obj, NULL, NULL, bb->head);
assert_true(res == UBUS_STATUS_OK);
// Check the results
struct json_object *jobj = get_json_obj_from_log();
assert_non_null(jobj);
struct json_object *tmp = json_object_get_by_string(jobj, "xtse");
assert_string_equal(json_object_get_string(tmp), xtse_val);
tmp = json_object_get_by_string(jobj, "vdsl2_profiles");
assert_string_equal(json_object_get_string(tmp), vdsl2_profiles_val);
tmp = json_object_get_by_string(jobj, "fast_profiles");
assert_string_equal(json_object_get_string(tmp), fast_profiles_val);
tmp = json_object_get_by_string(jobj, "limit_mask");
assert_int_equal(json_object_get_int(tmp), limit_mask_val);
tmp = json_object_get_by_string(jobj, "us0_mask");
assert_int_equal(json_object_get_int(tmp), us0_mask_val);
// Free the memory
json_object_put(jobj);
}
static void test_api_dsl_configure_fail(void **state)
{
const char *xtse_val = "00,00,00,00,00,00,00,00"; // invalid
const char *vdsl2_profiles_val = "30a,35b";
const char *fast_profiles_val = "106a";
struct test_ctx *ctx = (struct test_ctx *) *state;
struct blob_buf *bb = &ctx->bb;
struct ubus_object *obj = &ctx->dsl_line;
// Prepare the input parameters
blobmsg_add_string(bb, "xtse", xtse_val);
blobmsg_add_string(bb, "vdsl2_profiles", vdsl2_profiles_val);
blobmsg_add_string(bb, "fast_profiles", fast_profiles_val);
// Call the function to be tested
int res = dsl_line_configure(NULL, obj, NULL, NULL, bb->head);
assert_true(res != UBUS_STATUS_OK);
// Check the results
struct json_object *jobj = get_json_obj_from_log();
assert_non_null(jobj);
struct json_object *tmp = json_object_get_by_string(jobj, "xtse");
assert_string_equal(json_object_get_string(tmp), xtse_val);
tmp = json_object_get_by_string(jobj, "vdsl2_profiles");
assert_string_equal(json_object_get_string(tmp), vdsl2_profiles_val);
tmp = json_object_get_by_string(jobj, "fast_profiles");
assert_string_equal(json_object_get_string(tmp), fast_profiles_val);
// Free the memory
json_object_put(jobj);
}
static void test_api_atm_configure(void **state)
{
const char *link_type_val = "eoa";
const unsigned int vpi_val = 8; // invalid
const unsigned int vci_val = 35;
const char *qos_class_val = "ubr";
const unsigned int max_burst_size_val = 8124;
struct test_ctx *ctx = (struct test_ctx *) *state;
struct blob_buf *bb = &ctx->bb;
struct ubus_object *obj = &ctx->atm_link;
// Prepare the input parameters
blobmsg_add_string(bb, "link_type", link_type_val);
blobmsg_add_u32(bb, "vpi", vpi_val);
blobmsg_add_u32(bb, "vci", vci_val);
blobmsg_add_string(bb, "qos_class", qos_class_val);
blobmsg_add_u32(bb, "max_burst_size", max_burst_size_val);
// Call the function to be tested
int res = atm_link_configure(NULL, obj, NULL, NULL, bb->head);
assert_true(res == UBUS_STATUS_OK);
// Check the results
struct json_object *jobj = get_json_obj_from_log();
assert_non_null(jobj);
struct json_object *tmp = json_object_get_by_string(jobj, "link_type");
assert_string_equal(json_object_get_string(tmp), link_type_val);
tmp = json_object_get_by_string(jobj, "vpi");
assert_int_equal(json_object_get_int(tmp), vpi_val);
tmp = json_object_get_by_string(jobj, "vci");
assert_int_equal(json_object_get_int(tmp), vci_val);
tmp = json_object_get_by_string(jobj, "qos_class");
assert_string_equal(json_object_get_string(tmp), qos_class_val);
tmp = json_object_get_by_string(jobj, "max_burst_size");
assert_int_equal(json_object_get_int(tmp), max_burst_size_val);
// Free the memory
json_object_put(jobj);
}
static void test_api_atm_configure_fail(void **state)
{
const char *link_type_val = "eoa";
const unsigned int vpi_val = 0; // invalid
const unsigned int vci_val = 35;
const char *qos_class_val = "ubr";
struct test_ctx *ctx = (struct test_ctx *) *state;
struct blob_buf *bb = &ctx->bb;
struct ubus_object *obj = &ctx->atm_link;
// Prepare the input parameters
blobmsg_add_string(bb, "link_type", link_type_val);
blobmsg_add_u32(bb, "vpi", vpi_val);
blobmsg_add_u32(bb, "vci", vci_val);
blobmsg_add_string(bb, "qos_class", qos_class_val);
// Call the function to be tested
int res = atm_link_configure(NULL, obj, NULL, NULL, bb->head);
assert_true(res != UBUS_STATUS_OK);
// Check the results
struct json_object *jobj = get_json_obj_from_log();
assert_non_null(jobj);
struct json_object *tmp = json_object_get_by_string(jobj, "link_type");
assert_string_equal(json_object_get_string(tmp), link_type_val);
tmp = json_object_get_by_string(jobj, "vpi");
assert_int_equal(json_object_get_int(tmp), vpi_val);
tmp = json_object_get_by_string(jobj, "vci");
assert_int_equal(json_object_get_int(tmp), vci_val);
tmp = json_object_get_by_string(jobj, "qos_class");
assert_string_equal(json_object_get_string(tmp), qos_class_val);
// Free the memory
json_object_put(jobj);
}
int main(void) int main(void)
{ {
const struct CMUnitTest tests[] = { const struct CMUnitTest tests[] = {
...@@ -233,7 +450,11 @@ int main(void) ...@@ -233,7 +450,11 @@ int main(void)
cmocka_unit_test_setup_teardown(test_api_dsl_line_stats_interval, setup, teardown), cmocka_unit_test_setup_teardown(test_api_dsl_line_stats_interval, setup, teardown),
cmocka_unit_test_setup_teardown(test_api_dsl_channel_stats, setup, teardown), cmocka_unit_test_setup_teardown(test_api_dsl_channel_stats, setup, teardown),
cmocka_unit_test_setup_teardown(test_api_dsl_channel_stats_interval, setup, teardown), cmocka_unit_test_setup_teardown(test_api_dsl_channel_stats_interval, setup, teardown),
cmocka_unit_test_setup_teardown(test_api_dsl_stats, setup, teardown) cmocka_unit_test_setup_teardown(test_api_dsl_stats, setup, teardown),
cmocka_unit_test_setup_teardown(test_api_dsl_configure, setup, teardown),
cmocka_unit_test_setup_teardown(test_api_dsl_configure_fail, setup, teardown),
cmocka_unit_test_setup_teardown(test_api_atm_configure, setup, teardown),
cmocka_unit_test_setup_teardown(test_api_atm_configure_fail, setup, teardown)
}; };
return cmocka_run_group_tests(tests, group_setup, group_teardown); return cmocka_run_group_tests(tests, group_setup, group_teardown);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment