chsrc/test/fw.c

76 lines
1.9 KiB
C
Raw Normal View History

2024-12-14 19:07:20 +08:00
/** ------------------------------------------------------------
* SPDX-License-Identifier: GPL-3.0-or-later
* -------------------------------------------------------------
* File Authors : Aoran Zeng <ccmywish@qq.com>
* Contributors : Nil Null <nil@null.org>
* |
* Created On : <2024-12-14>
* Last Modified : <2024-12-14>
* ------------------------------------------------------------*/
2024-12-14 19:52:08 +08:00
#define Chsrc_Version "Frameworker"
2024-12-14 19:07:20 +08:00
#include "../src/framework/core.c"
int
main (int argc, char const *argv[])
{
2024-12-14 19:52:08 +08:00
if (argc == 2 && xy_streql (argv[1], "--version"))
{
say (Chsrc_Version);
return 0;
}
2024-12-14 22:42:50 +08:00
xy_useutf8();
2024-12-14 19:52:08 +08:00
2024-12-14 19:07:20 +08:00
br();
chsrc_log ("chsrc_log");
chsrc_succ ("chsrc_succ");
chsrc_info ("chsrc_info");
chsrc_warn ("chsrc_warn");
chsrc_error ("chsrc_error");
chsrc_debug ("chsrc_debug");
chsrc_verbose ("chsrc_verbose");
chsrc_succ2 ("chsrc_succ2");
2024-12-14 19:52:08 +08:00
chsrc_log2 ("chsrc_log2");
2024-12-14 19:07:20 +08:00
chsrc_note2 ("chsrc_note2");
chsrc_warn2 ("chsrc_warn2");
chsrc_error2 ("chsrc_error2");
chsrc_debug2 ("chsrc_debug2");
chsrc_verbose2 ("chsrc_verbose2");
2024-12-14 22:42:50 +08:00
#ifdef XY_On_Windows
#define fw ".\\fw.exe"
#else
#define fw "./fw"
#endif
2024-12-14 19:52:08 +08:00
2024-12-14 22:42:50 +08:00
assert (chsrc_check_program (fw));
assert (chsrc_check_program_quietly (fw));
assert (chsrc_check_program_quietly_when_exist (fw));
chsrc_ensure_program (fw);
2024-12-14 19:52:08 +08:00
#define bkup "README.md.bak"
2024-12-14 19:07:20 +08:00
chsrc_backup ("README.md");
2024-12-14 19:52:08 +08:00
assert (chsrc_check_file (bkup));
chsrc_ensure_dir ("test");
chsrc_append_to_file ("append", bkup);
2024-12-14 22:42:50 +08:00
if (!xy_on_windows)
{
chsrc_prepend_to_file ("prepend", bkup);
}
2024-12-14 19:52:08 +08:00
chsrc_overwrite_file ("overwrite", bkup);
chsrc_view_file (bkup);
chsrc_log (xy_2strjoin ("CPU arch = ", chsrc_get_cpuarch ()));
printf ("chsrc: CPU cores = ");
puti (chsrc_get_cpucore ());
chsrc_run ("rm " bkup, RunOpt_No_Last_New_Line);
chsrc_run ("echo " Chsrc_Version " test pass!", RunOpt_Dont_Notify_On_Success);
2024-12-14 19:07:20 +08:00
return 0;
}