• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ArkScript-lang / Ark / 15453345670

04 Jun 2025 09:40PM UTC coverage: 86.735% (+0.1%) from 86.608%
15453345670

push

github

SuperFola
chore: updating fuzzing corpus

2 of 3 new or added lines in 2 files covered. (66.67%)

140 existing lines in 7 files now uncovered.

7258 of 8368 relevant lines covered (86.74%)

120482.26 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

27.5
/src/arkreactor/Builtins/System.cpp
1
#include <Ark/Builtins/Builtins.hpp>
2

3
#include <stdio.h>
4
#include <memory>
5
#include <cstdlib>
6
#include <thread>
7

8
#ifdef _MSC_VER
9
#    define popen _popen
10
#    define pclose _pclose
11
#endif
12

13
#undef abs
14
#include <chrono>
15

16
#include <Ark/Constants.hpp>
17
#include <Ark/TypeChecker.hpp>
18
#include <Ark/VM/VM.hpp>
19

20
namespace Ark::internal::Builtins::System
21
{
22
    namespace
23
    {
24
        struct close_file_deleter
25
        {
26
            int operator()(FILE* file) const noexcept
×
27
            {
×
28
                return pclose(file);
×
29
            }
30
        };
31
    }
32

33
    // cppcheck-suppress constParameterReference
UNCOV
34
    Value system_(std::vector<Value>& n, VM* vm [[maybe_unused]])
×
UNCOV
35
    {
×
UNCOV
36
        if (!types::check(n, ValueType::String))
×
UNCOV
37
            throw types::TypeCheckingError(
×
UNCOV
38
                "sys:exec",
×
UNCOV
39
                { { types::Contract { { types::Typedef("command", ValueType::String) } } } },
×
UNCOV
40
                n);
×
41

42
#if defined(ARK_ENABLE_SYSTEM) && !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
NEW
43
        std::array<char, 128> buffer {};
×
44
        std::string result;
×
45
        std::unique_ptr<FILE, close_file_deleter> pipe(popen(n[0].string().c_str(), "r"), close_file_deleter());
×
46
        if (!pipe)
×
47
            throw std::runtime_error("sys:exec: couldn't retrieve command output");
×
48
        while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr)
×
49
            result += buffer.data();
×
50
        return Value(result);
×
51
#else
52
        return nil;
53
#endif  // ARK_ENABLE_SYSTEM
54
    }
×
55

56
    // cppcheck-suppress constParameterReference
57
    Value sleep(std::vector<Value>& n, VM* vm [[maybe_unused]])
3✔
58
    {
3✔
59
        if (!types::check(n, ValueType::Number))
3✔
60
            throw types::TypeCheckingError(
2✔
61
                "sys:sleep",
1✔
62
                { { types::Contract { { types::Typedef("duration", ValueType::Number) } } } },
1✔
63
                n);
1✔
64

65
        auto duration = std::chrono::duration<double, std::ratio<1, 1000>>(n[0].number());
2✔
66
        std::this_thread::sleep_for(duration);
2✔
67

68
        return nil;
2✔
69
    }
3✔
70

71
    // cppcheck-suppress constParameterReference
UNCOV
72
    Value exit_(std::vector<Value>& n, VM* vm)
×
UNCOV
73
    {
×
UNCOV
74
        if (!types::check(n, ValueType::Number))
×
UNCOV
75
            throw types::TypeCheckingError(
×
UNCOV
76
                "sys:exit",
×
UNCOV
77
                { { types::Contract { { types::Typedef("exitCode", ValueType::Number) } } } },
×
UNCOV
78
                n);
×
79

UNCOV
80
        vm->exit(static_cast<int>(n[0].number()));
×
UNCOV
81
        return nil;
×
UNCOV
82
    }
×
83
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc