summaryrefslogtreecommitdiffstats
path: root/test/vpnor/tmpd.cpp
blob: 6bdfa090b61f63ac68fe61e0f2b244ec4a2815f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2018 IBM Corp.

#include "test/vpnor/tmpd.hpp"

namespace openpower
{
namespace virtual_pnor
{
namespace test
{

namespace fs = std::experimental::filesystem;

size_t VpnorRoot::write(const std::string &name, const void *data, size_t len)
{
    // write() is for test environment setup - always write to ro section
    fs::path path = root / "ro" / name;

    if (!fs::exists(path))
        /* It's not in the ToC */
        throw std::invalid_argument(name);

    std::ofstream(path).write((const char *)data, len);

    return len;
}

} // test
} // virtual_pnor
} // openpower
OpenPOWER on IntegriCloud