aboutsummaryrefslogtreecommitdiffstats
path: root/3rdparty/pybind11/tests/test_embed/catch.cpp
blob: dd137385cb32250b8640169934fb96aa5e80f069 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// The Catch implementation is compiled here. This is a standalone
// translation unit to avoid recompiling it for every test change.

#include <pybind11/embed.h>

#ifdef _MSC_VER
// Silence MSVC C++17 deprecation warning from Catch regarding std::uncaught_exceptions (up to catch
// 2.0.1; this should be fixed in the next catch release after 2.0.1).
#  pragma warning(disable: 4996)
#endif

#define CATCH_CONFIG_RUNNER
#include <catch.hpp>

namespace py = pybind11;

int main(int argc, char *argv[]) {
    py::scoped_interpreter guard{};
    auto result = Catch::Session().run(argc, argv);

    return result < 0xff ? result : 0xff;
}
chips which have RDID */ int probe_spi_st95(struct flashctx *flash) { /* * ST_M95_RDID_OUTSIZE depends on size of the flash and * not all ST_M95XXX have RDID. */ static const unsigned char cmd[ST_M95_RDID_OUTSIZE_MAX] = { ST_M95_RDID }; unsigned char readarr[ST_M95_RDID_INSIZE]; uint32_t id1, id2; int ret; uint32_t rdid_outsize = ST_M95_RDID_2BA_OUTSIZE; // 16 bit address if (flash->chip->total_size * KiB > 64 * KiB) rdid_outsize = ST_M95_RDID_3BA_OUTSIZE; // 24 bit address ret = spi_send_command(flash, rdid_outsize, sizeof(readarr), cmd, readarr); if (ret) return ret; id1 = readarr[0]; // manufacture id id2 = (readarr[1] << 8) | readarr[2]; // SPI family code + model id msg_cdbg("%s: id1 0x%02x, id2 0x%02x\n", __func__, id1, id2); if (id1 == flash->chip->manufacture_id && id2 == flash->chip->model_id) return 1; return 0; } /* ST95XXX chips don't have erase operation and erase is made as part of write command */ int spi_block_erase_emulation(struct flashctx *flash, unsigned int addr, unsigned int blocklen) { uint8_t *erased_contents = NULL; int result = 0; erased_contents = (uint8_t *)malloc(blocklen * sizeof(uint8_t)); if (!erased_contents) { msg_cerr("Out of memory!\n"); return 1; } memset(erased_contents, ERASED_VALUE(flash), blocklen * sizeof(uint8_t)); result = spi_write_chunked(flash, erased_contents, 0, blocklen, flash->chip->page_size); free(erased_contents); return result; }