mirror of
https://github.com/hyprwm/hyprutils.git
synced 2026-04-08 12:20:36 +02:00
* Add missing includes. * Add libc++ < 20 fallback for floating-point strToNumber libc++ prior to version 20 does not implement std::from_chars for floating point types, which causes builds to fail on systems using older libc++ versions (e.g. FreeBSD). Add a small fallback using strtof/strtod/strtold for building with libc++ < 20. While libstdc++, or libc++ 20 or later continue to use the existing std::from_chars implementation, this change restores compatibility with older libc++ versions.
31 lines
No EOL
921 B
C++
31 lines
No EOL
921 B
C++
#include <hyprutils/os/Process.hpp>
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <sys/types.h>
|
|
#include <signal.h>
|
|
|
|
using namespace Hyprutils::OS;
|
|
|
|
TEST(OS, process) {
|
|
CProcess process("sh", {"-c", "echo \"Hello $WORLD!\""});
|
|
process.addEnv("WORLD", "World");
|
|
|
|
EXPECT_EQ(process.runAsync(), true);
|
|
EXPECT_EQ(process.runSync(), true);
|
|
|
|
EXPECT_EQ(process.stdOut(), std::string{"Hello World!\n"});
|
|
EXPECT_EQ(process.stdErr(), std::string{""});
|
|
EXPECT_EQ(process.exitCode(), 0);
|
|
|
|
CProcess process2("sh", {"-c", "while true; do sleep 1; done;"});
|
|
|
|
EXPECT_EQ(process2.runAsync(), true);
|
|
EXPECT_EQ(getpgid(process2.pid()) >= 0, true);
|
|
|
|
kill(process2.pid(), SIGKILL);
|
|
|
|
CProcess process3("sh", {"-c", "cat /geryueruggbuergheruger/reugiheruygyuerghuryeghyer/eruihgyuerguyerghyuerghuyergerguyer/NON_EXISTENT"});
|
|
EXPECT_EQ(process3.runSync(), true);
|
|
EXPECT_EQ(process3.exitCode(), 1);
|
|
} |