A metronome using the FRDM K64F board

Committer:
ram54288
Date:
Sun May 14 18:40:18 2017 +0000
Revision:
0:a7a43371b306
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ram54288 0:a7a43371b306 1 /*
ram54288 0:a7a43371b306 2 * Copyright (c) 2015 ARM Limited. All rights reserved.
ram54288 0:a7a43371b306 3 * SPDX-License-Identifier: Apache-2.0
ram54288 0:a7a43371b306 4 * Licensed under the Apache License, Version 2.0 (the License); you may
ram54288 0:a7a43371b306 5 * not use this file except in compliance with the License.
ram54288 0:a7a43371b306 6 * You may obtain a copy of the License at
ram54288 0:a7a43371b306 7 *
ram54288 0:a7a43371b306 8 * http://www.apache.org/licenses/LICENSE-2.0
ram54288 0:a7a43371b306 9 *
ram54288 0:a7a43371b306 10 * Unless required by applicable law or agreed to in writing, software
ram54288 0:a7a43371b306 11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
ram54288 0:a7a43371b306 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ram54288 0:a7a43371b306 13 * See the License for the specific language governing permissions and
ram54288 0:a7a43371b306 14 * limitations under the License.
ram54288 0:a7a43371b306 15 */
ram54288 0:a7a43371b306 16 #include "CppUTest/TestHarness.h"
ram54288 0:a7a43371b306 17 #include "test_m2mdevice.h"
ram54288 0:a7a43371b306 18 #include "m2mobject_stub.h"
ram54288 0:a7a43371b306 19 #include "m2mobjectinstance_stub.h"
ram54288 0:a7a43371b306 20 #include "m2mresource_stub.h"
ram54288 0:a7a43371b306 21 #include "m2mresourceinstance_stub.h"
ram54288 0:a7a43371b306 22 #include "m2mbase_stub.h"
ram54288 0:a7a43371b306 23
ram54288 0:a7a43371b306 24 Test_M2MDevice::Test_M2MDevice()
ram54288 0:a7a43371b306 25 {
ram54288 0:a7a43371b306 26 M2MObject* obj = new M2MObject("name", "name");
ram54288 0:a7a43371b306 27 m2mobject_stub::inst = new M2MObjectInstance(*obj,
ram54288 0:a7a43371b306 28 "name",
ram54288 0:a7a43371b306 29 "","");
ram54288 0:a7a43371b306 30 m2mobjectinstance_stub::resource = new M2MResource(*m2mobject_stub::inst,
ram54288 0:a7a43371b306 31 "name",
ram54288 0:a7a43371b306 32 "type",
ram54288 0:a7a43371b306 33 M2MResourceInstance::STRING,
ram54288 0:a7a43371b306 34 false,
ram54288 0:a7a43371b306 35 "name");
ram54288 0:a7a43371b306 36
ram54288 0:a7a43371b306 37 m2mobjectinstance_stub::create_resource_instance= new M2MResourceInstance(*m2mobjectinstance_stub::resource,
ram54288 0:a7a43371b306 38 "name",
ram54288 0:a7a43371b306 39 "type",
ram54288 0:a7a43371b306 40 M2MResourceInstance::STRING,
ram54288 0:a7a43371b306 41 0,
ram54288 0:a7a43371b306 42 "name",
ram54288 0:a7a43371b306 43 false);
ram54288 0:a7a43371b306 44 m2mresource_stub::bool_value = true;
ram54288 0:a7a43371b306 45 m2mobjectinstance_stub::create_resource = new M2MResource(*m2mobject_stub::inst,
ram54288 0:a7a43371b306 46 "name",
ram54288 0:a7a43371b306 47 "type",
ram54288 0:a7a43371b306 48 M2MResourceInstance::STRING,
ram54288 0:a7a43371b306 49 false,
ram54288 0:a7a43371b306 50 "name");
ram54288 0:a7a43371b306 51 device = M2MDevice::get_instance();
ram54288 0:a7a43371b306 52
ram54288 0:a7a43371b306 53 delete m2mobjectinstance_stub::create_resource;
ram54288 0:a7a43371b306 54 m2mobjectinstance_stub::create_resource = NULL;
ram54288 0:a7a43371b306 55
ram54288 0:a7a43371b306 56 delete m2mobjectinstance_stub::resource;
ram54288 0:a7a43371b306 57 m2mobjectinstance_stub::resource = NULL;
ram54288 0:a7a43371b306 58
ram54288 0:a7a43371b306 59 delete m2mobjectinstance_stub::create_resource_instance;
ram54288 0:a7a43371b306 60 m2mobjectinstance_stub::create_resource_instance = NULL;
ram54288 0:a7a43371b306 61
ram54288 0:a7a43371b306 62 delete obj;
ram54288 0:a7a43371b306 63 }
ram54288 0:a7a43371b306 64
ram54288 0:a7a43371b306 65 Test_M2MDevice::~Test_M2MDevice()
ram54288 0:a7a43371b306 66 {
ram54288 0:a7a43371b306 67 delete m2mobject_stub::inst;
ram54288 0:a7a43371b306 68 m2mobject_stub::inst = NULL;
ram54288 0:a7a43371b306 69
ram54288 0:a7a43371b306 70 M2MDevice::delete_instance();
ram54288 0:a7a43371b306 71 device = NULL;
ram54288 0:a7a43371b306 72 }
ram54288 0:a7a43371b306 73
ram54288 0:a7a43371b306 74 void Test_M2MDevice::test_create_resource_instance()
ram54288 0:a7a43371b306 75 {
ram54288 0:a7a43371b306 76 m2mobjectinstance_stub::create_resource_instance = new M2MResourceInstance(*m2mobjectinstance_stub::resource,
ram54288 0:a7a43371b306 77 "name",
ram54288 0:a7a43371b306 78 "type",
ram54288 0:a7a43371b306 79 M2MResourceInstance::STRING,
ram54288 0:a7a43371b306 80 0,
ram54288 0:a7a43371b306 81 "name",
ram54288 0:a7a43371b306 82 false);
ram54288 0:a7a43371b306 83
ram54288 0:a7a43371b306 84 m2mobjectinstance_stub::resource = new M2MResource(*m2mobject_stub::inst,
ram54288 0:a7a43371b306 85 "name",
ram54288 0:a7a43371b306 86 "type",
ram54288 0:a7a43371b306 87 M2MResourceInstance::STRING,
ram54288 0:a7a43371b306 88 false,
ram54288 0:a7a43371b306 89 "name");
ram54288 0:a7a43371b306 90
ram54288 0:a7a43371b306 91 CHECK(device->create_resource_instance(M2MDevice::ErrorCode,5,1) != NULL);
ram54288 0:a7a43371b306 92 CHECK(device->create_resource_instance(M2MDevice::ErrorCode,-1,1) == NULL);
ram54288 0:a7a43371b306 93 CHECK(device->create_resource_instance(M2MDevice::ErrorCode,9,1) == NULL);
ram54288 0:a7a43371b306 94
ram54288 0:a7a43371b306 95 m2mbase_stub::void_value = malloc(20);
ram54288 0:a7a43371b306 96
ram54288 0:a7a43371b306 97 CHECK(device->create_resource_instance(M2MDevice::AvailablePowerSources,-1,0) == NULL);
ram54288 0:a7a43371b306 98 CHECK(device->create_resource_instance(M2MDevice::AvailablePowerSources,8,0) == NULL);
ram54288 0:a7a43371b306 99 CHECK(device->create_resource_instance(M2MDevice::AvailablePowerSources,7,0) != NULL);
ram54288 0:a7a43371b306 100 CHECK(M2MBase::GET_ALLOWED == m2mbase_stub::operation);
ram54288 0:a7a43371b306 101
ram54288 0:a7a43371b306 102 CHECK(device->create_resource_instance(M2MDevice::PowerSourceVoltage,10,0) != NULL);
ram54288 0:a7a43371b306 103 CHECK(M2MBase::GET_ALLOWED == m2mbase_stub::operation);
ram54288 0:a7a43371b306 104
ram54288 0:a7a43371b306 105 CHECK(device->create_resource_instance(M2MDevice::PowerSourceCurrent,10,0) != NULL);
ram54288 0:a7a43371b306 106 CHECK(M2MBase::GET_ALLOWED == m2mbase_stub::operation);
ram54288 0:a7a43371b306 107
ram54288 0:a7a43371b306 108 free(m2mbase_stub::void_value);
ram54288 0:a7a43371b306 109 delete m2mobjectinstance_stub::create_resource_instance;
ram54288 0:a7a43371b306 110 m2mobjectinstance_stub::create_resource_instance = NULL;
ram54288 0:a7a43371b306 111
ram54288 0:a7a43371b306 112 delete m2mobjectinstance_stub::resource;
ram54288 0:a7a43371b306 113 m2mobjectinstance_stub::resource = NULL;
ram54288 0:a7a43371b306 114 }
ram54288 0:a7a43371b306 115
ram54288 0:a7a43371b306 116 void Test_M2MDevice::test_create_resource_string()
ram54288 0:a7a43371b306 117 {
ram54288 0:a7a43371b306 118 m2mresourceinstance_stub::value = NULL;
ram54288 0:a7a43371b306 119 CHECK(device->create_resource(M2MDevice::Reboot,"test") == NULL);
ram54288 0:a7a43371b306 120 CHECK(device->create_resource(M2MDevice::ErrorCode,"test") == NULL);
ram54288 0:a7a43371b306 121 CHECK(device->create_resource(M2MDevice::SupportedBindingMode,"test") == NULL);
ram54288 0:a7a43371b306 122 // Length 65, should fail
ram54288 0:a7a43371b306 123 String max_lenght = "65656565656565656565656565656565656565656565656565656565656565656";
ram54288 0:a7a43371b306 124 m2mobjectinstance_stub::create_resource = new M2MResource(*m2mobject_stub::inst,
ram54288 0:a7a43371b306 125 "name",
ram54288 0:a7a43371b306 126 "type",
ram54288 0:a7a43371b306 127 M2MResourceInstance::STRING,
ram54288 0:a7a43371b306 128 false,
ram54288 0:a7a43371b306 129 "name");
ram54288 0:a7a43371b306 130
ram54288 0:a7a43371b306 131 CHECK(device->create_resource(M2MDevice::Manufacturer,"test") != NULL);
ram54288 0:a7a43371b306 132 CHECK(M2MBase::GET_ALLOWED == m2mbase_stub::operation);
ram54288 0:a7a43371b306 133
ram54288 0:a7a43371b306 134 CHECK(device->create_resource(M2MDevice::Manufacturer,max_lenght) == NULL);
ram54288 0:a7a43371b306 135 CHECK(M2MBase::GET_ALLOWED == m2mbase_stub::operation);
ram54288 0:a7a43371b306 136
ram54288 0:a7a43371b306 137 m2mobjectinstance_stub::resource = new M2MResource(*m2mobject_stub::inst,
ram54288 0:a7a43371b306 138 "name",
ram54288 0:a7a43371b306 139 "type",
ram54288 0:a7a43371b306 140 M2MResourceInstance::STRING,
ram54288 0:a7a43371b306 141 false,
ram54288 0:a7a43371b306 142 "name");
ram54288 0:a7a43371b306 143 m2mresource_stub::bool_value = false;
ram54288 0:a7a43371b306 144 //Duplicate resource
ram54288 0:a7a43371b306 145 CHECK(device->create_resource(M2MDevice::Manufacturer,"test") == NULL);
ram54288 0:a7a43371b306 146
ram54288 0:a7a43371b306 147 delete m2mobjectinstance_stub::resource;
ram54288 0:a7a43371b306 148 m2mobjectinstance_stub::resource = NULL;
ram54288 0:a7a43371b306 149
ram54288 0:a7a43371b306 150 CHECK(device->create_resource(M2MDevice::DeviceType,"test") != NULL);
ram54288 0:a7a43371b306 151 CHECK(M2MBase::GET_ALLOWED == m2mbase_stub::operation);
ram54288 0:a7a43371b306 152 CHECK(device->create_resource(M2MDevice::DeviceType,"") != NULL);
ram54288 0:a7a43371b306 153 CHECK(device->create_resource(M2MDevice::DeviceType,max_lenght) == NULL);
ram54288 0:a7a43371b306 154
ram54288 0:a7a43371b306 155 CHECK(device->create_resource(M2MDevice::ModelNumber,"test") != NULL);
ram54288 0:a7a43371b306 156 CHECK(M2MBase::GET_ALLOWED == m2mbase_stub::operation);
ram54288 0:a7a43371b306 157 CHECK(device->create_resource(M2MDevice::ModelNumber,max_lenght) == NULL);
ram54288 0:a7a43371b306 158
ram54288 0:a7a43371b306 159
ram54288 0:a7a43371b306 160 CHECK(device->create_resource(M2MDevice::SerialNumber,"test") != NULL);
ram54288 0:a7a43371b306 161 CHECK(M2MBase::GET_ALLOWED == m2mbase_stub::operation);
ram54288 0:a7a43371b306 162 CHECK(device->create_resource(M2MDevice::SerialNumber,max_lenght) == NULL);
ram54288 0:a7a43371b306 163
ram54288 0:a7a43371b306 164
ram54288 0:a7a43371b306 165 CHECK(device->create_resource(M2MDevice::HardwareVersion,"test") != NULL);
ram54288 0:a7a43371b306 166 CHECK(M2MBase::GET_ALLOWED == m2mbase_stub::operation);
ram54288 0:a7a43371b306 167 CHECK(device->create_resource(M2MDevice::HardwareVersion,max_lenght) == NULL);
ram54288 0:a7a43371b306 168
ram54288 0:a7a43371b306 169
ram54288 0:a7a43371b306 170 CHECK(device->create_resource(M2MDevice::FirmwareVersion,"test") != NULL);
ram54288 0:a7a43371b306 171 CHECK(M2MBase::GET_ALLOWED == m2mbase_stub::operation);
ram54288 0:a7a43371b306 172 CHECK(device->create_resource(M2MDevice::FirmwareVersion,max_lenght) == NULL);
ram54288 0:a7a43371b306 173
ram54288 0:a7a43371b306 174
ram54288 0:a7a43371b306 175 CHECK(device->create_resource(M2MDevice::SoftwareVersion,"test") != NULL);
ram54288 0:a7a43371b306 176 CHECK(M2MBase::GET_ALLOWED == m2mbase_stub::operation);
ram54288 0:a7a43371b306 177 CHECK(device->create_resource(M2MDevice::SoftwareVersion,max_lenght) == NULL);
ram54288 0:a7a43371b306 178
ram54288 0:a7a43371b306 179
ram54288 0:a7a43371b306 180 CHECK(device->create_resource(M2MDevice::UTCOffset,"test") != NULL);
ram54288 0:a7a43371b306 181 CHECK(M2MBase::GET_PUT_ALLOWED == m2mbase_stub::operation);
ram54288 0:a7a43371b306 182 CHECK(device->create_resource(M2MDevice::UTCOffset,max_lenght) == NULL);
ram54288 0:a7a43371b306 183
ram54288 0:a7a43371b306 184
ram54288 0:a7a43371b306 185 CHECK(device->create_resource(M2MDevice::Timezone,"test") != NULL);
ram54288 0:a7a43371b306 186 CHECK(M2MBase::GET_PUT_ALLOWED == m2mbase_stub::operation);
ram54288 0:a7a43371b306 187 CHECK(device->create_resource(M2MDevice::Timezone,max_lenght) == NULL);
ram54288 0:a7a43371b306 188
ram54288 0:a7a43371b306 189 CHECK(device->create_resource(M2MDevice::BatteryLevel,"test") == NULL);
ram54288 0:a7a43371b306 190 CHECK(device->create_resource(M2MDevice::BatteryStatus,"test") == NULL);
ram54288 0:a7a43371b306 191 CHECK(device->create_resource(M2MDevice::MemoryFree,"test") == NULL);
ram54288 0:a7a43371b306 192 CHECK(device->create_resource(M2MDevice::MemoryTotal,"test") == NULL);
ram54288 0:a7a43371b306 193 CHECK(device->create_resource(M2MDevice::ResetErrorCode,"test") == NULL);
ram54288 0:a7a43371b306 194 CHECK(device->create_resource(M2MDevice::CurrentTime,"test") == NULL);
ram54288 0:a7a43371b306 195 CHECK(device->create_resource(M2MDevice::AvailablePowerSources,"test") == NULL);
ram54288 0:a7a43371b306 196 CHECK(device->create_resource(M2MDevice::PowerSourceVoltage,"test") == NULL);
ram54288 0:a7a43371b306 197 CHECK(device->create_resource(M2MDevice::PowerSourceCurrent,"test") == NULL);
ram54288 0:a7a43371b306 198 CHECK(device->create_resource(M2MDevice::FactoryReset,"test") == NULL);
ram54288 0:a7a43371b306 199
ram54288 0:a7a43371b306 200 delete m2mobjectinstance_stub::create_resource;
ram54288 0:a7a43371b306 201 m2mobjectinstance_stub::create_resource = NULL;
ram54288 0:a7a43371b306 202 }
ram54288 0:a7a43371b306 203
ram54288 0:a7a43371b306 204 void Test_M2MDevice::test_create_resource_int()
ram54288 0:a7a43371b306 205 {
ram54288 0:a7a43371b306 206 m2mobjectinstance_stub::create_resource = new M2MResource(*m2mobject_stub::inst,
ram54288 0:a7a43371b306 207 "name",
ram54288 0:a7a43371b306 208 "type",
ram54288 0:a7a43371b306 209 M2MResourceInstance::STRING,
ram54288 0:a7a43371b306 210 false,
ram54288 0:a7a43371b306 211 "name");
ram54288 0:a7a43371b306 212
ram54288 0:a7a43371b306 213 CHECK(device->create_resource(M2MDevice::Reboot,10) == NULL);
ram54288 0:a7a43371b306 214 CHECK(device->create_resource(M2MDevice::SupportedBindingMode,10) == NULL);
ram54288 0:a7a43371b306 215
ram54288 0:a7a43371b306 216 CHECK(device->create_resource(M2MDevice::Manufacturer,10) == NULL);
ram54288 0:a7a43371b306 217 CHECK(device->create_resource(M2MDevice::DeviceType,10) == NULL);
ram54288 0:a7a43371b306 218 CHECK(device->create_resource(M2MDevice::ModelNumber,10) == NULL);
ram54288 0:a7a43371b306 219 CHECK(device->create_resource(M2MDevice::SerialNumber,10) == NULL);
ram54288 0:a7a43371b306 220 CHECK(device->create_resource(M2MDevice::HardwareVersion,10) == NULL);
ram54288 0:a7a43371b306 221 CHECK(device->create_resource(M2MDevice::FirmwareVersion,10) == NULL);
ram54288 0:a7a43371b306 222 CHECK(device->create_resource(M2MDevice::SoftwareVersion,10) == NULL);
ram54288 0:a7a43371b306 223 CHECK(device->create_resource(M2MDevice::UTCOffset,10) == NULL);
ram54288 0:a7a43371b306 224 CHECK(device->create_resource(M2MDevice::Timezone,10) == NULL);
ram54288 0:a7a43371b306 225 CHECK(device->create_resource(M2MDevice::FactoryReset,10) == NULL);
ram54288 0:a7a43371b306 226
ram54288 0:a7a43371b306 227 m2mbase_stub::void_value = malloc(20);
ram54288 0:a7a43371b306 228
ram54288 0:a7a43371b306 229 CHECK(device->create_resource(M2MDevice::BatteryLevel,10) != NULL);
ram54288 0:a7a43371b306 230 CHECK(M2MBase::GET_ALLOWED == m2mbase_stub::operation);
ram54288 0:a7a43371b306 231
ram54288 0:a7a43371b306 232 // Range is above 100
ram54288 0:a7a43371b306 233 CHECK(device->create_resource(M2MDevice::BatteryLevel,101) == NULL);
ram54288 0:a7a43371b306 234
ram54288 0:a7a43371b306 235 CHECK(device->create_resource(M2MDevice::BatteryStatus,4) != NULL);
ram54288 0:a7a43371b306 236 CHECK(M2MBase::GET_ALLOWED == m2mbase_stub::operation);
ram54288 0:a7a43371b306 237
ram54288 0:a7a43371b306 238 // Range is above 6
ram54288 0:a7a43371b306 239 CHECK(device->create_resource(M2MDevice::BatteryStatus,10) == NULL);
ram54288 0:a7a43371b306 240
ram54288 0:a7a43371b306 241 CHECK(device->create_resource(M2MDevice::MemoryFree,10) != NULL);
ram54288 0:a7a43371b306 242 CHECK(M2MBase::GET_ALLOWED == m2mbase_stub::operation);
ram54288 0:a7a43371b306 243
ram54288 0:a7a43371b306 244 CHECK(device->create_resource(M2MDevice::MemoryTotal,10) != NULL);
ram54288 0:a7a43371b306 245 CHECK(M2MBase::GET_ALLOWED == m2mbase_stub::operation);
ram54288 0:a7a43371b306 246
ram54288 0:a7a43371b306 247 CHECK(device->create_resource(M2MDevice::CurrentTime,10) != NULL);
ram54288 0:a7a43371b306 248 CHECK(M2MBase::GET_PUT_ALLOWED == m2mbase_stub::operation);
ram54288 0:a7a43371b306 249
ram54288 0:a7a43371b306 250 free(m2mbase_stub::void_value);
ram54288 0:a7a43371b306 251 delete m2mobjectinstance_stub::create_resource;
ram54288 0:a7a43371b306 252 m2mobjectinstance_stub::create_resource = NULL;
ram54288 0:a7a43371b306 253 }
ram54288 0:a7a43371b306 254
ram54288 0:a7a43371b306 255 void Test_M2MDevice::test_create_resource_no_param()
ram54288 0:a7a43371b306 256 {
ram54288 0:a7a43371b306 257 m2mobjectinstance_stub::create_resource = new M2MResource(*m2mobject_stub::inst,
ram54288 0:a7a43371b306 258 "name",
ram54288 0:a7a43371b306 259 "type",
ram54288 0:a7a43371b306 260 M2MResourceInstance::STRING,
ram54288 0:a7a43371b306 261 false,
ram54288 0:a7a43371b306 262 "name");
ram54288 0:a7a43371b306 263
ram54288 0:a7a43371b306 264
ram54288 0:a7a43371b306 265 CHECK(device->create_resource(M2MDevice::Reboot) == NULL);
ram54288 0:a7a43371b306 266 CHECK(device->create_resource(M2MDevice::ErrorCode) == NULL);
ram54288 0:a7a43371b306 267 CHECK(device->create_resource(M2MDevice::SupportedBindingMode) == NULL);
ram54288 0:a7a43371b306 268
ram54288 0:a7a43371b306 269 CHECK(device->create_resource(M2MDevice::Manufacturer) == NULL);
ram54288 0:a7a43371b306 270 CHECK(device->create_resource(M2MDevice::DeviceType) == NULL);
ram54288 0:a7a43371b306 271 CHECK(device->create_resource(M2MDevice::ModelNumber) == NULL);
ram54288 0:a7a43371b306 272 CHECK(device->create_resource(M2MDevice::SerialNumber) == NULL);
ram54288 0:a7a43371b306 273 CHECK(device->create_resource(M2MDevice::HardwareVersion) == NULL);
ram54288 0:a7a43371b306 274 CHECK(device->create_resource(M2MDevice::FirmwareVersion) == NULL);
ram54288 0:a7a43371b306 275 CHECK(device->create_resource(M2MDevice::SoftwareVersion) == NULL);
ram54288 0:a7a43371b306 276 CHECK(device->create_resource(M2MDevice::UTCOffset) == NULL);
ram54288 0:a7a43371b306 277 CHECK(device->create_resource(M2MDevice::Timezone) == NULL);
ram54288 0:a7a43371b306 278
ram54288 0:a7a43371b306 279 CHECK(device->create_resource(M2MDevice::BatteryLevel) == NULL);
ram54288 0:a7a43371b306 280 CHECK(device->create_resource(M2MDevice::BatteryStatus) == NULL);
ram54288 0:a7a43371b306 281 CHECK(device->create_resource(M2MDevice::MemoryFree) == NULL);
ram54288 0:a7a43371b306 282 CHECK(device->create_resource(M2MDevice::MemoryTotal) == NULL);
ram54288 0:a7a43371b306 283 CHECK(device->create_resource(M2MDevice::CurrentTime) == NULL);
ram54288 0:a7a43371b306 284 CHECK(device->create_resource(M2MDevice::AvailablePowerSources) == NULL);
ram54288 0:a7a43371b306 285 CHECK(device->create_resource(M2MDevice::PowerSourceVoltage) == NULL);
ram54288 0:a7a43371b306 286 CHECK(device->create_resource(M2MDevice::PowerSourceCurrent) == NULL);
ram54288 0:a7a43371b306 287
ram54288 0:a7a43371b306 288 m2mobjectinstance_stub::resource = new M2MResource(*m2mobject_stub::inst,
ram54288 0:a7a43371b306 289 "name",
ram54288 0:a7a43371b306 290 "type",
ram54288 0:a7a43371b306 291 M2MResourceInstance::STRING,
ram54288 0:a7a43371b306 292 false,
ram54288 0:a7a43371b306 293 "name");
ram54288 0:a7a43371b306 294
ram54288 0:a7a43371b306 295 CHECK(device->create_resource(M2MDevice::ResetErrorCode) != NULL);
ram54288 0:a7a43371b306 296
ram54288 0:a7a43371b306 297 CHECK(device->create_resource(M2MDevice::FactoryReset) != NULL);
ram54288 0:a7a43371b306 298
ram54288 0:a7a43371b306 299 delete m2mobjectinstance_stub::resource;
ram54288 0:a7a43371b306 300 m2mobjectinstance_stub::resource = NULL;
ram54288 0:a7a43371b306 301
ram54288 0:a7a43371b306 302 CHECK(M2MBase::POST_ALLOWED == m2mbase_stub::operation);
ram54288 0:a7a43371b306 303
ram54288 0:a7a43371b306 304 delete m2mobjectinstance_stub::create_resource;
ram54288 0:a7a43371b306 305 m2mobjectinstance_stub::create_resource = NULL;
ram54288 0:a7a43371b306 306
ram54288 0:a7a43371b306 307
ram54288 0:a7a43371b306 308 }
ram54288 0:a7a43371b306 309
ram54288 0:a7a43371b306 310 void Test_M2MDevice::test_delete_resource()
ram54288 0:a7a43371b306 311 {
ram54288 0:a7a43371b306 312 m2mobjectinstance_stub::bool_value = true;
ram54288 0:a7a43371b306 313
ram54288 0:a7a43371b306 314 CHECK(device->delete_resource(M2MDevice::Reboot) == false);
ram54288 0:a7a43371b306 315 CHECK(device->delete_resource(M2MDevice::ErrorCode) == false);
ram54288 0:a7a43371b306 316 CHECK(device->delete_resource(M2MDevice::SupportedBindingMode) == false);
ram54288 0:a7a43371b306 317
ram54288 0:a7a43371b306 318 CHECK(device->delete_resource(M2MDevice::Manufacturer) == true);
ram54288 0:a7a43371b306 319 CHECK(device->delete_resource(M2MDevice::BatteryLevel) == true);
ram54288 0:a7a43371b306 320 CHECK(device->delete_resource(M2MDevice::FactoryReset) == true);
ram54288 0:a7a43371b306 321 }
ram54288 0:a7a43371b306 322
ram54288 0:a7a43371b306 323 void Test_M2MDevice::test_delete_resource_instance()
ram54288 0:a7a43371b306 324 {
ram54288 0:a7a43371b306 325 m2mobjectinstance_stub::bool_value = true;
ram54288 0:a7a43371b306 326
ram54288 0:a7a43371b306 327 CHECK(device->delete_resource_instance(M2MDevice::Reboot,0) == false);
ram54288 0:a7a43371b306 328 CHECK(device->delete_resource_instance(M2MDevice::ErrorCode,0) == false);
ram54288 0:a7a43371b306 329 CHECK(device->delete_resource_instance(M2MDevice::SupportedBindingMode,0) == false);
ram54288 0:a7a43371b306 330
ram54288 0:a7a43371b306 331 CHECK(device->delete_resource_instance(M2MDevice::AvailablePowerSources,0) == true);
ram54288 0:a7a43371b306 332 CHECK(device->delete_resource_instance(M2MDevice::PowerSourceVoltage,0) == true);
ram54288 0:a7a43371b306 333 CHECK(device->delete_resource_instance(M2MDevice::PowerSourceCurrent,0) == true);
ram54288 0:a7a43371b306 334 }
ram54288 0:a7a43371b306 335
ram54288 0:a7a43371b306 336 void Test_M2MDevice::test_set_resource_value_string()
ram54288 0:a7a43371b306 337 {
ram54288 0:a7a43371b306 338 // Length 65, should fail
ram54288 0:a7a43371b306 339 m2mresourceinstance_stub::value = NULL;
ram54288 0:a7a43371b306 340 String max_lenght = "65656565656565656565656565656565656565656565656565656565656565656";
ram54288 0:a7a43371b306 341 m2mbase_stub::bool_value = true;
ram54288 0:a7a43371b306 342 m2mresourceinstance_stub::bool_value = true;
ram54288 0:a7a43371b306 343
ram54288 0:a7a43371b306 344 m2mobjectinstance_stub::resource = new M2MResource(*m2mobject_stub::inst,
ram54288 0:a7a43371b306 345 "name",
ram54288 0:a7a43371b306 346 "type",
ram54288 0:a7a43371b306 347 M2MResourceInstance::STRING,
ram54288 0:a7a43371b306 348 false,
ram54288 0:a7a43371b306 349 "name");
ram54288 0:a7a43371b306 350 m2mresource_stub::bool_value = false;
ram54288 0:a7a43371b306 351
ram54288 0:a7a43371b306 352 m2mbase_stub::void_value = malloc(20);
ram54288 0:a7a43371b306 353
ram54288 0:a7a43371b306 354 CHECK(device->set_resource_value(M2MDevice::Reboot,"test") == false);
ram54288 0:a7a43371b306 355 CHECK(device->set_resource_value(M2MDevice::ErrorCode,"test") == false);
ram54288 0:a7a43371b306 356 CHECK(device->set_resource_value(M2MDevice::SupportedBindingMode,"test") == false);
ram54288 0:a7a43371b306 357
ram54288 0:a7a43371b306 358 CHECK(device->set_resource_value(M2MDevice::Manufacturer,"test") == true);
ram54288 0:a7a43371b306 359 CHECK(device->set_resource_value(M2MDevice::Manufacturer,"") == true);
ram54288 0:a7a43371b306 360 CHECK(device->set_resource_value(M2MDevice::Manufacturer,max_lenght) == false);
ram54288 0:a7a43371b306 361 CHECK(device->set_resource_value(M2MDevice::DeviceType,"test") == true);
ram54288 0:a7a43371b306 362 CHECK(device->set_resource_value(M2MDevice::DeviceType,max_lenght) == false);
ram54288 0:a7a43371b306 363 CHECK(device->set_resource_value(M2MDevice::ModelNumber,"test") == true);
ram54288 0:a7a43371b306 364 CHECK(device->set_resource_value(M2MDevice::ModelNumber,max_lenght) == false);
ram54288 0:a7a43371b306 365 CHECK(device->set_resource_value(M2MDevice::SerialNumber,"test") == true);
ram54288 0:a7a43371b306 366 CHECK(device->set_resource_value(M2MDevice::SerialNumber,max_lenght) == false);
ram54288 0:a7a43371b306 367 CHECK(device->set_resource_value(M2MDevice::HardwareVersion,"test") == true);
ram54288 0:a7a43371b306 368 CHECK(device->set_resource_value(M2MDevice::HardwareVersion,max_lenght) == false);
ram54288 0:a7a43371b306 369 CHECK(device->set_resource_value(M2MDevice::FirmwareVersion,"test") == true);
ram54288 0:a7a43371b306 370 CHECK(device->set_resource_value(M2MDevice::FirmwareVersion,max_lenght) == false);
ram54288 0:a7a43371b306 371 CHECK(device->set_resource_value(M2MDevice::SoftwareVersion,"test") == true);
ram54288 0:a7a43371b306 372 CHECK(device->set_resource_value(M2MDevice::SoftwareVersion,max_lenght) == false);
ram54288 0:a7a43371b306 373 CHECK(device->set_resource_value(M2MDevice::UTCOffset,"test") == true);
ram54288 0:a7a43371b306 374 CHECK(device->set_resource_value(M2MDevice::UTCOffset,max_lenght) == false);
ram54288 0:a7a43371b306 375 CHECK(device->set_resource_value(M2MDevice::Timezone,"test") == true);
ram54288 0:a7a43371b306 376 CHECK(device->set_resource_value(M2MDevice::Timezone,max_lenght) == false);
ram54288 0:a7a43371b306 377 CHECK(device->set_resource_value(M2MDevice::Timezone,"") == true);
ram54288 0:a7a43371b306 378
ram54288 0:a7a43371b306 379 CHECK(device->set_resource_value(M2MDevice::BatteryLevel,"test") == false);
ram54288 0:a7a43371b306 380 CHECK(device->set_resource_value(M2MDevice::BatteryStatus,"test") == false);
ram54288 0:a7a43371b306 381 CHECK(device->set_resource_value(M2MDevice::MemoryFree,"test") == false);
ram54288 0:a7a43371b306 382 CHECK(device->set_resource_value(M2MDevice::MemoryTotal,"test") == false);
ram54288 0:a7a43371b306 383 CHECK(device->set_resource_value(M2MDevice::ResetErrorCode,"test") == false);
ram54288 0:a7a43371b306 384 CHECK(device->set_resource_value(M2MDevice::CurrentTime,"test") == false);
ram54288 0:a7a43371b306 385 CHECK(device->set_resource_value(M2MDevice::AvailablePowerSources,"test") == false);
ram54288 0:a7a43371b306 386 CHECK(device->set_resource_value(M2MDevice::PowerSourceVoltage,"test") == false);
ram54288 0:a7a43371b306 387 CHECK(device->set_resource_value(M2MDevice::PowerSourceCurrent,"test") == false);
ram54288 0:a7a43371b306 388 CHECK(device->set_resource_value(M2MDevice::FactoryReset,"test") == false);
ram54288 0:a7a43371b306 389
ram54288 0:a7a43371b306 390 free(m2mbase_stub::void_value);
ram54288 0:a7a43371b306 391 delete m2mobjectinstance_stub::resource;
ram54288 0:a7a43371b306 392 m2mobjectinstance_stub::resource = NULL;
ram54288 0:a7a43371b306 393 }
ram54288 0:a7a43371b306 394
ram54288 0:a7a43371b306 395 void Test_M2MDevice::test_set_resource_value_int()
ram54288 0:a7a43371b306 396 {
ram54288 0:a7a43371b306 397 m2mresourceinstance_stub::bool_value = true;
ram54288 0:a7a43371b306 398
ram54288 0:a7a43371b306 399 m2mobjectinstance_stub::resource = new M2MResource(*m2mobject_stub::inst,
ram54288 0:a7a43371b306 400 "name",
ram54288 0:a7a43371b306 401 "type",
ram54288 0:a7a43371b306 402 M2MResourceInstance::STRING,
ram54288 0:a7a43371b306 403 false,
ram54288 0:a7a43371b306 404 "name");
ram54288 0:a7a43371b306 405 m2mresource_stub::bool_value = false;
ram54288 0:a7a43371b306 406
ram54288 0:a7a43371b306 407 m2mbase_stub::void_value = malloc(20);
ram54288 0:a7a43371b306 408
ram54288 0:a7a43371b306 409 CHECK(device->set_resource_value(M2MDevice::Reboot,10) == false);
ram54288 0:a7a43371b306 410 CHECK(device->set_resource_value(M2MDevice::SupportedBindingMode,10) == false);
ram54288 0:a7a43371b306 411
ram54288 0:a7a43371b306 412 CHECK(device->set_resource_value(M2MDevice::Manufacturer,10) == false);
ram54288 0:a7a43371b306 413 CHECK(device->set_resource_value(M2MDevice::DeviceType,10) == false);
ram54288 0:a7a43371b306 414 CHECK(device->set_resource_value(M2MDevice::ModelNumber,10) == false);
ram54288 0:a7a43371b306 415 CHECK(device->set_resource_value(M2MDevice::SerialNumber,10) == false);
ram54288 0:a7a43371b306 416 CHECK(device->set_resource_value(M2MDevice::HardwareVersion,10) == false);
ram54288 0:a7a43371b306 417 CHECK(device->set_resource_value(M2MDevice::FirmwareVersion,10) == false);
ram54288 0:a7a43371b306 418 CHECK(device->set_resource_value(M2MDevice::SoftwareVersion,10) == false);
ram54288 0:a7a43371b306 419 CHECK(device->set_resource_value(M2MDevice::UTCOffset,10) == false);
ram54288 0:a7a43371b306 420 CHECK(device->set_resource_value(M2MDevice::Timezone,10) == false);
ram54288 0:a7a43371b306 421
ram54288 0:a7a43371b306 422 CHECK(device->set_resource_value(M2MDevice::BatteryLevel,-1) == false);
ram54288 0:a7a43371b306 423 CHECK(device->set_resource_value(M2MDevice::BatteryLevel,10) == true);
ram54288 0:a7a43371b306 424 CHECK(device->set_resource_value(M2MDevice::BatteryLevel,101) == false);
ram54288 0:a7a43371b306 425 CHECK(device->set_resource_value(M2MDevice::BatteryStatus,6) == true);
ram54288 0:a7a43371b306 426 CHECK(device->set_resource_value(M2MDevice::BatteryStatus,-1) == false);
ram54288 0:a7a43371b306 427 CHECK(device->set_resource_value(M2MDevice::BatteryStatus,7) == false);
ram54288 0:a7a43371b306 428 CHECK(device->set_resource_value(M2MDevice::MemoryFree,10) == true);
ram54288 0:a7a43371b306 429 CHECK(device->set_resource_value(M2MDevice::MemoryTotal,10) == true);
ram54288 0:a7a43371b306 430 CHECK(device->set_resource_value(M2MDevice::CurrentTime,10) == true);
ram54288 0:a7a43371b306 431 CHECK(device->set_resource_value(M2MDevice::FactoryReset,10) == false);
ram54288 0:a7a43371b306 432
ram54288 0:a7a43371b306 433 free(m2mbase_stub::void_value);
ram54288 0:a7a43371b306 434 delete m2mobjectinstance_stub::resource;
ram54288 0:a7a43371b306 435 m2mobjectinstance_stub::resource = NULL;
ram54288 0:a7a43371b306 436 }
ram54288 0:a7a43371b306 437
ram54288 0:a7a43371b306 438 void Test_M2MDevice::test_resource_value_int()
ram54288 0:a7a43371b306 439 {
ram54288 0:a7a43371b306 440 uint8_t value[] = {"10"};
ram54288 0:a7a43371b306 441 uint8_t* ptr = (uint8_t*)malloc((uint32_t)sizeof(value));
ram54288 0:a7a43371b306 442 m2mresourceinstance_stub::value = ptr;
ram54288 0:a7a43371b306 443 memset(m2mresourceinstance_stub::value,0,(uint32_t)sizeof(value));
ram54288 0:a7a43371b306 444 memcpy(m2mresourceinstance_stub::value,value,sizeof(value));
ram54288 0:a7a43371b306 445 m2mresourceinstance_stub::int_value = (uint32_t)sizeof(value);
ram54288 0:a7a43371b306 446
ram54288 0:a7a43371b306 447 m2mobjectinstance_stub::resource = new M2MResource(*m2mobject_stub::inst,
ram54288 0:a7a43371b306 448 "name",
ram54288 0:a7a43371b306 449 "type",
ram54288 0:a7a43371b306 450 M2MResourceInstance::STRING,
ram54288 0:a7a43371b306 451 false,
ram54288 0:a7a43371b306 452 "name");
ram54288 0:a7a43371b306 453
ram54288 0:a7a43371b306 454 m2mresourceinstance_stub::bool_value = true;
ram54288 0:a7a43371b306 455 m2mresource_stub::bool_value = false;
ram54288 0:a7a43371b306 456 m2mbase_stub::void_value = malloc(20);
ram54288 0:a7a43371b306 457
ram54288 0:a7a43371b306 458 CHECK(device->resource_value_int(M2MDevice::BatteryLevel) == 10);
ram54288 0:a7a43371b306 459 CHECK(device->resource_value_int(M2MDevice::BatteryStatus) == 10);
ram54288 0:a7a43371b306 460 CHECK(device->resource_value_int(M2MDevice::MemoryFree) == 10);
ram54288 0:a7a43371b306 461 CHECK(device->resource_value_int(M2MDevice::MemoryTotal) == 10);
ram54288 0:a7a43371b306 462 CHECK(device->resource_value_int(M2MDevice::ErrorCode) == 10);
ram54288 0:a7a43371b306 463 CHECK(device->resource_value_int(M2MDevice::CurrentTime) == 10);
ram54288 0:a7a43371b306 464 CHECK(device->resource_value_int(M2MDevice::AvailablePowerSources) == 10);
ram54288 0:a7a43371b306 465 CHECK(device->resource_value_int(M2MDevice::PowerSourceVoltage) == 10);
ram54288 0:a7a43371b306 466 CHECK(device->resource_value_int(M2MDevice::PowerSourceCurrent) == 10);
ram54288 0:a7a43371b306 467 CHECK(device->resource_value_int(M2MDevice::Manufacturer) == -1);
ram54288 0:a7a43371b306 468
ram54288 0:a7a43371b306 469 m2mresource_stub::instance= new M2MResourceInstance(*m2mobjectinstance_stub::resource,
ram54288 0:a7a43371b306 470 "name",
ram54288 0:a7a43371b306 471 "type",
ram54288 0:a7a43371b306 472 M2MResourceInstance::STRING,
ram54288 0:a7a43371b306 473 0,
ram54288 0:a7a43371b306 474 "name",
ram54288 0:a7a43371b306 475 false);
ram54288 0:a7a43371b306 476 m2mresource_stub::bool_value = true;
ram54288 0:a7a43371b306 477 CHECK(device->resource_value_int(M2MDevice::AvailablePowerSources,1) == 10);
ram54288 0:a7a43371b306 478
ram54288 0:a7a43371b306 479 free(m2mbase_stub::void_value);
ram54288 0:a7a43371b306 480
ram54288 0:a7a43371b306 481 delete m2mresource_stub::instance;
ram54288 0:a7a43371b306 482 m2mresource_stub::instance = NULL;
ram54288 0:a7a43371b306 483
ram54288 0:a7a43371b306 484 delete m2mobjectinstance_stub::resource;
ram54288 0:a7a43371b306 485 m2mobjectinstance_stub::resource = NULL;
ram54288 0:a7a43371b306 486
ram54288 0:a7a43371b306 487 free(ptr);
ram54288 0:a7a43371b306 488 }
ram54288 0:a7a43371b306 489
ram54288 0:a7a43371b306 490 void Test_M2MDevice::test_resource_value_string()
ram54288 0:a7a43371b306 491 {
ram54288 0:a7a43371b306 492 String test = "string";
ram54288 0:a7a43371b306 493 uint8_t value[] = {"string"};
ram54288 0:a7a43371b306 494 m2mresourceinstance_stub::value = (uint8_t*)malloc((uint32_t)sizeof(value));
ram54288 0:a7a43371b306 495 memset(m2mresourceinstance_stub::value,0,(uint32_t)sizeof(value));
ram54288 0:a7a43371b306 496 memcpy(m2mresourceinstance_stub::value,value,sizeof(value));
ram54288 0:a7a43371b306 497 m2mresourceinstance_stub::int_value = (uint32_t)sizeof(value);
ram54288 0:a7a43371b306 498
ram54288 0:a7a43371b306 499 m2mobjectinstance_stub::resource = new M2MResource(*m2mobject_stub::inst,
ram54288 0:a7a43371b306 500 "name",
ram54288 0:a7a43371b306 501 "type",
ram54288 0:a7a43371b306 502 M2MResourceInstance::STRING,
ram54288 0:a7a43371b306 503 false,
ram54288 0:a7a43371b306 504 "name");
ram54288 0:a7a43371b306 505
ram54288 0:a7a43371b306 506 m2mresourceinstance_stub::bool_value = true;
ram54288 0:a7a43371b306 507 m2mresource_stub::bool_value = false;
ram54288 0:a7a43371b306 508 m2mbase_stub::void_value = malloc(20);
ram54288 0:a7a43371b306 509
ram54288 0:a7a43371b306 510 CHECK(device->resource_value_string(M2MDevice::Manufacturer) == test);
ram54288 0:a7a43371b306 511 CHECK(device->resource_value_string(M2MDevice::DeviceType) == test);
ram54288 0:a7a43371b306 512 CHECK(device->resource_value_string(M2MDevice::ModelNumber) == test);
ram54288 0:a7a43371b306 513 CHECK(device->resource_value_string(M2MDevice::SerialNumber) == test);
ram54288 0:a7a43371b306 514 CHECK(device->resource_value_string(M2MDevice::HardwareVersion) == test);
ram54288 0:a7a43371b306 515 CHECK(device->resource_value_string(M2MDevice::FirmwareVersion) == test);
ram54288 0:a7a43371b306 516 CHECK(device->resource_value_string(M2MDevice::SoftwareVersion) == test);
ram54288 0:a7a43371b306 517 CHECK(device->resource_value_string(M2MDevice::UTCOffset) == test);
ram54288 0:a7a43371b306 518 CHECK(device->resource_value_string(M2MDevice::Timezone) == test);
ram54288 0:a7a43371b306 519 CHECK(device->resource_value_string(M2MDevice::BatteryLevel) == "");
ram54288 0:a7a43371b306 520
ram54288 0:a7a43371b306 521 free(m2mbase_stub::void_value);
ram54288 0:a7a43371b306 522
ram54288 0:a7a43371b306 523 delete m2mobjectinstance_stub::resource;
ram54288 0:a7a43371b306 524 m2mobjectinstance_stub::resource = NULL;
ram54288 0:a7a43371b306 525
ram54288 0:a7a43371b306 526 free(m2mresourceinstance_stub::value);
ram54288 0:a7a43371b306 527 m2mresourceinstance_stub::value = NULL;
ram54288 0:a7a43371b306 528 }
ram54288 0:a7a43371b306 529
ram54288 0:a7a43371b306 530 void Test_M2MDevice::test_is_resource_present()
ram54288 0:a7a43371b306 531 {
ram54288 0:a7a43371b306 532 m2mobjectinstance_stub::resource = new M2MResource(*m2mobject_stub::inst,
ram54288 0:a7a43371b306 533 "name",
ram54288 0:a7a43371b306 534 "type",
ram54288 0:a7a43371b306 535 M2MResourceInstance::STRING,
ram54288 0:a7a43371b306 536 false,
ram54288 0:a7a43371b306 537 "name");
ram54288 0:a7a43371b306 538 m2mresource_stub::bool_value = false;
ram54288 0:a7a43371b306 539 CHECK(device->is_resource_present(M2MDevice::Reboot) == true);
ram54288 0:a7a43371b306 540
ram54288 0:a7a43371b306 541 delete m2mobjectinstance_stub::resource;
ram54288 0:a7a43371b306 542 m2mobjectinstance_stub::resource = NULL;
ram54288 0:a7a43371b306 543
ram54288 0:a7a43371b306 544 CHECK(device->is_resource_present(M2MDevice::Manufacturer) == false);
ram54288 0:a7a43371b306 545 CHECK(device->is_resource_present(M2MDevice::DeviceType) == false);
ram54288 0:a7a43371b306 546 }
ram54288 0:a7a43371b306 547
ram54288 0:a7a43371b306 548 void Test_M2MDevice::test_per_resource_count()
ram54288 0:a7a43371b306 549 {
ram54288 0:a7a43371b306 550 m2mobjectinstance_stub::int_value = 1;
ram54288 0:a7a43371b306 551 CHECK(device->per_resource_count(M2MDevice::Reboot) == 1);
ram54288 0:a7a43371b306 552
ram54288 0:a7a43371b306 553 m2mobjectinstance_stub::int_value = 0;
ram54288 0:a7a43371b306 554
ram54288 0:a7a43371b306 555 CHECK(device->per_resource_count(M2MDevice::Manufacturer) == 0);
ram54288 0:a7a43371b306 556 }
ram54288 0:a7a43371b306 557
ram54288 0:a7a43371b306 558 void Test_M2MDevice::test_total_resource_count()
ram54288 0:a7a43371b306 559 {
ram54288 0:a7a43371b306 560 M2MResource res(*m2mobject_stub::inst,"test","test",M2MResourceInstance::STRING,false, "test");
ram54288 0:a7a43371b306 561
ram54288 0:a7a43371b306 562 m2mobjectinstance_stub::resource_list.push_back(&res);
ram54288 0:a7a43371b306 563 M2MResource res2(*m2mobject_stub::inst,"test","test",M2MResourceInstance::STRING,false, "test");
ram54288 0:a7a43371b306 564
ram54288 0:a7a43371b306 565 m2mobjectinstance_stub::resource_list.push_back(&res2);
ram54288 0:a7a43371b306 566
ram54288 0:a7a43371b306 567 CHECK(device->total_resource_count() == 2);
ram54288 0:a7a43371b306 568
ram54288 0:a7a43371b306 569 m2mobjectinstance_stub::resource_list.clear();
ram54288 0:a7a43371b306 570 }
ram54288 0:a7a43371b306 571