Pytest embedded idf
pytest_embedded_idf.app
IdfApp
Bases: App
Idf App class
Attributes:
Name | Type | Description |
---|---|---|
elf_file |
str
|
elf file path |
flash_args |
dict[str, Any]
|
dict of flasher_args.json |
flash_files |
list[FlashFile]
|
list of (offset, file path, encrypted) of files need to be flashed in |
flash_settings |
dict[str, Any]
|
dict of flash settings |
Source code in pytest_embedded_idf/app.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
|
partition_table: Dict[str, Any]
property
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
partition table dict generated by the partition tool |
parttool_path: str
property
Returns:
Type | Description |
---|---|
str
|
Partition tool path |
sdkconfig: Dict[str, Any]
property
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
dict contains all k-v pairs from the sdkconfig file |
target: str
property
Returns:
Type | Description |
---|---|
str
|
target chip type |
get_sha256(filepath)
Get the sha256 of the file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filepath |
str
|
path to the file |
required |
Returns:
Type | Description |
---|---|
Optional[str]
|
sha256 value appended to app |
Source code in pytest_embedded_idf/app.py
pytest_embedded_idf.serial
IdfSerial
Bases: EspSerial
IDF serial Dut class
Auto flash the app while starting test.
Source code in pytest_embedded_idf/serial.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
|
dump_flash(partition=None, address=None, size=None, output=None)
Dump the flash bytes into the output file by partition name or by start address and size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
output |
Union[str, TextIO, None]
|
file path or file stream to write to. File stream should be opened with bytes mode. |
None
|
partition |
Optional[str]
|
partition name |
None
|
address |
Optional[str]
|
address that start reading from |
None
|
size |
Optional[str]
|
read size |
None
|
Returns:
Type | Description |
---|---|
Optional[bytes]
|
None if |
Optional[bytes]
|
bytes if |
Source code in pytest_embedded_idf/serial.py
erase_partition(partition_name)
Erase the partition provided
Parameters:
Name | Type | Description | Default |
---|---|---|---|
partition_name |
str
|
partition name |
required |
Source code in pytest_embedded_idf/serial.py
flash()
Flash the app.flash_files
to the dut
Source code in pytest_embedded_idf/serial.py
is_target_flashed_same_elf()
Check if the sha256 values are matched between the flashed target and the self.app.elf_file
Returns:
Type | Description |
---|---|
bool
|
True if the sha256 values are matched |
Source code in pytest_embedded_idf/serial.py
read_flash_elf_sha256()
Read the sha256 digest of the flashed elf file
Returns:
Type | Description |
---|---|
bytes
|
bytes of sha256 |
Source code in pytest_embedded_idf/serial.py
pytest_embedded_idf.dut
IdfDut
Bases: SerialDut
Dut class for serial ports connect to Espressif boards which are flashed with ESP-IDF apps
Attributes:
Name | Type | Description |
---|---|---|
target |
str
|
target chip type |
skip_check_coredump |
bool
|
skip check core dumped or not while dut teardown if set to True |
Source code in pytest_embedded_idf/dut.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 |
|
panic_output_decode_script: t.Optional[str]
property
Returns:
Type | Description |
---|---|
t.Optional[str]
|
Panic output decode script path |
toolchain_prefix: str
property
Returns:
Type | Description |
---|---|
str
|
Toolchain prefix according to the |
run_all_single_board_cases(group=None, reset=False, timeout=30, run_ignore_cases=False)
Run all multi_stage cases
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
t.Optional[str]
|
test case group |
None
|
reset |
bool
|
whether to perform a hardware reset before running a case |
False
|
timeout |
float
|
timeout. (Default: 30 seconds) |
30
|
run_ignore_cases |
bool
|
run ignored test cases or not |
False
|
Source code in pytest_embedded_idf/dut.py
pytest_embedded_idf.unity_tester
CaseTester
The Generic tester of all the types
Attributes:
Name | Type | Description |
---|---|---|
group |
t.List[MultiDevResource]
|
The group of the devices' resources |
dut |
IdfDut
|
The first dut if there is more than one |
test_menu |
t.List[UnittestMenuCase]
|
The list of the cases |
Source code in pytest_embedded_idf/unity_tester.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
|
__init__(dut)
Create the object for every dut and put them into the group
Source code in pytest_embedded_idf/unity_tester.py
run_all_cases(reset=False, timeout=DEFAULT_TIMEOUT, start_retry=DEFAULT_START_RETRY)
Run all cases
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reset |
bool
|
whether to perform a hardware reset before running a case |
False
|
timeout |
int
|
timeout in second |
DEFAULT_TIMEOUT
|
start_retry |
int
|
number of retries for a single case when it is failed to start |
DEFAULT_START_RETRY
|
Source code in pytest_embedded_idf/unity_tester.py
run_all_multi_dev_cases(reset=False, timeout=DEFAULT_TIMEOUT, start_retry=DEFAULT_START_RETRY)
Run only multi_device cases
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reset |
bool
|
whether to perform a hardware reset before running a case |
False
|
timeout |
float
|
timeout in second |
DEFAULT_TIMEOUT
|
start_retry |
int
|
number of retries for a single case when it is failed to start |
DEFAULT_START_RETRY
|
Source code in pytest_embedded_idf/unity_tester.py
run_case(case, reset=False, timeout=DEFAULT_TIMEOUT, start_retry=DEFAULT_START_RETRY)
Run a specific case
Parameters:
Name | Type | Description | Default |
---|---|---|---|
case |
UnittestMenuCase
|
the specific case that parsed in test menu |
required |
reset |
bool
|
whether to perform a hardware reset before running a case |
False
|
timeout |
int
|
timeout in second |
DEFAULT_TIMEOUT
|
start_retry |
int
|
number of retries for a single case when it is failed to start |
DEFAULT_START_RETRY
|
Source code in pytest_embedded_idf/unity_tester.py
run_multi_dev_case(case, reset=False, timeout=DEFAULT_TIMEOUT, start_retry=DEFAULT_START_RETRY)
Run a specific multi_device case
Notes
Will skip with a warning if the case type is not multi_device
Parameters:
Name | Type | Description | Default |
---|---|---|---|
case |
UnittestMenuCase
|
the specific case that parsed in test menu |
required |
reset |
bool
|
whether to perform a hardware reset before running a case |
False
|
timeout |
float
|
timeout in second |
DEFAULT_TIMEOUT
|
start_retry |
int
|
number of retries for a single case when it is failed to start |
DEFAULT_START_RETRY
|
Source code in pytest_embedded_idf/unity_tester.py
MultiDevResource
Resources of multi_dev dut
Attributes:
Name | Type | Description |
---|---|---|
dut |
IdfDut
|
Object of the Device under test |
sem |
Semaphore
|
Semaphore of monitoring whether the case finished |
recv_sig |
t.List[str]
|
The list of received signals from other dut |
thread |
Thread
|
The thread of monitoring the signals |
Source code in pytest_embedded_idf/unity_tester.py
UnittestMenuCase
dataclass
Dataclass of esp-idf unit test cases parsed from test menu
Attributes:
Name | Type | Description |
---|---|---|
index |
int
|
The index of the case, which can be used to run this case. |
name |
str
|
The name of the case. |
type |
str
|
Type of this case, which can be |
keywords |
t.List[str]
|
List of additional keywords of this case. For now, we have |
groups |
t.List[str]
|
List of groups of this case, this is usually the component which this case belongs to. |
attributes |
t.Dict[str, t.Any]
|
Dict of attributes of this case, which is used to describe timeout duration, test environment, etc. |
subcases |
t.List[t.Dict[str, t.Any]]
|
List of dict of subcases of this case, if this case is a |