mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
Test: Mark compilation-unit-only functions as static
This enables a nice warning in case a function becomes dead code. Also, in the case of test-crypto.cpp, I took the liberty to add the prefix 'g_' to the global event loop.
This commit is contained in:
parent
2b76f48a17
commit
76da9a4a7d
Notes:
sideshowbarker
2024-07-19 03:42:41 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/76da9a4a7d1 Pull-request: https://github.com/SerenityOS/serenity/pull/3096 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/stelar7
9 changed files with 191 additions and 192 deletions
|
@ -42,7 +42,7 @@ struct worker_t {
|
|||
long int wait_time;
|
||||
};
|
||||
|
||||
void* run_worker(void* args)
|
||||
static void* run_worker(void* args)
|
||||
{
|
||||
struct timespec time_to_wait = { 0, 0 };
|
||||
worker_t* worker = (worker_t*)args;
|
||||
|
@ -65,7 +65,7 @@ void* run_worker(void* args)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void init_worker(worker_t* worker, const char* name, long int wait_time)
|
||||
static void init_worker(worker_t* worker, const char* name, long int wait_time)
|
||||
{
|
||||
worker->name = name;
|
||||
worker->wait_time = wait_time;
|
||||
|
|
|
@ -256,7 +256,7 @@ constexpr size_t NUM_TESTCASES = sizeof(TESTCASES) / sizeof(TESTCASES[0]);
|
|||
|
||||
typedef double (*strtod_fn_t)(const char* str, char** endptr);
|
||||
|
||||
long long cast_ll(double d)
|
||||
static long long cast_ll(double d)
|
||||
{
|
||||
union readable_t {
|
||||
double as_double;
|
||||
|
@ -273,7 +273,7 @@ long long cast_ll(double d)
|
|||
return readable.as_ll;
|
||||
}
|
||||
|
||||
bool is_strtod_close(strtod_fn_t strtod_fn, const char* test_string, const char* expect_hex, int expect_consume, long long expect_ll)
|
||||
static bool is_strtod_close(strtod_fn_t strtod_fn, const char* test_string, const char* expect_hex, int expect_consume, long long expect_ll)
|
||||
{
|
||||
union readable_t {
|
||||
double as_double;
|
||||
|
@ -324,7 +324,7 @@ bool is_strtod_close(strtod_fn_t strtod_fn, const char* test_string, const char*
|
|||
return !(wrong_hex || error_cns || wrong_cns);
|
||||
}
|
||||
|
||||
long long hex_to_ll(const char* hex)
|
||||
static long long hex_to_ll(const char* hex)
|
||||
{
|
||||
long long result = 0;
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
|
|
|
@ -37,7 +37,7 @@ struct SortableObject {
|
|||
int m_payload;
|
||||
};
|
||||
|
||||
int compare_sortable_object(const void* a, const void* b)
|
||||
static int compare_sortable_object(const void* a, const void* b)
|
||||
{
|
||||
const int key1 = static_cast<const SortableObject*>(a)->m_key;
|
||||
const int key2 = static_cast<const SortableObject*>(b)->m_key;
|
||||
|
@ -50,13 +50,13 @@ int compare_sortable_object(const void* a, const void* b)
|
|||
}
|
||||
}
|
||||
|
||||
int calc_payload_for_pos(size_t pos)
|
||||
static int calc_payload_for_pos(size_t pos)
|
||||
{
|
||||
pos *= 231;
|
||||
return pos ^ (pos << 8) ^ (pos << 16) ^ (pos << 24);
|
||||
}
|
||||
|
||||
void shuffle_vec(Vector<SortableObject>& test_objects)
|
||||
static void shuffle_vec(Vector<SortableObject>& test_objects)
|
||||
{
|
||||
for (size_t i = 0; i < test_objects.size() * 3; ++i) {
|
||||
auto i1 = rand() % test_objects.size();
|
||||
|
|
|
@ -33,12 +33,12 @@
|
|||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
void test_invalid(int);
|
||||
void test_no_route(int);
|
||||
void test_valid(int);
|
||||
void test_send(int);
|
||||
static void test_invalid(int);
|
||||
static void test_no_route(int);
|
||||
static void test_valid(int);
|
||||
static void test_send(int);
|
||||
|
||||
void test(AK::Function<void(int)> test_fn)
|
||||
static void test(AK::Function<void(int)> test_fn)
|
||||
{
|
||||
|
||||
int fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
|
|
|
@ -70,36 +70,36 @@ constexpr const char* DEFAULT_SERVER { "www.google.com" };
|
|||
|
||||
// listAllTests
|
||||
// Cipher
|
||||
int aes_cbc_tests();
|
||||
int aes_ctr_tests();
|
||||
static int aes_cbc_tests();
|
||||
static int aes_ctr_tests();
|
||||
|
||||
// Hash
|
||||
int md5_tests();
|
||||
int sha1_tests();
|
||||
int sha256_tests();
|
||||
int sha512_tests();
|
||||
static int md5_tests();
|
||||
static int sha1_tests();
|
||||
static int sha256_tests();
|
||||
static int sha512_tests();
|
||||
|
||||
// Authentication
|
||||
int hmac_md5_tests();
|
||||
int hmac_sha256_tests();
|
||||
int hmac_sha512_tests();
|
||||
static int hmac_md5_tests();
|
||||
static int hmac_sha256_tests();
|
||||
static int hmac_sha512_tests();
|
||||
|
||||
// Public-Key
|
||||
int rsa_tests();
|
||||
static int rsa_tests();
|
||||
|
||||
// TLS
|
||||
int tls_tests();
|
||||
static int tls_tests();
|
||||
|
||||
// Big Integer
|
||||
int bigint_tests();
|
||||
static int bigint_tests();
|
||||
|
||||
// Checksum
|
||||
int adler32_tests();
|
||||
int crc32_tests();
|
||||
static int adler32_tests();
|
||||
static int crc32_tests();
|
||||
|
||||
// stop listing tests
|
||||
|
||||
void print_buffer(const ReadonlyBytes& buffer, int split)
|
||||
static void print_buffer(const ReadonlyBytes& buffer, int split)
|
||||
{
|
||||
for (size_t i = 0; i < buffer.size(); ++i) {
|
||||
if (split > 0) {
|
||||
|
@ -117,8 +117,9 @@ void print_buffer(const ReadonlyBytes& buffer, int split)
|
|||
puts("");
|
||||
}
|
||||
|
||||
Core::EventLoop loop;
|
||||
int run(Function<void(const char*, size_t)> fn)
|
||||
static Core::EventLoop g_loop;
|
||||
|
||||
static int run(Function<void(const char*, size_t)> fn)
|
||||
{
|
||||
if (interactive) {
|
||||
auto editor = Line::Editor::construct();
|
||||
|
@ -131,10 +132,10 @@ int run(Function<void(const char*, size_t)> fn)
|
|||
auto& line = line_result.value();
|
||||
|
||||
if (line == ".wait") {
|
||||
loop.exec();
|
||||
g_loop.exec();
|
||||
} else {
|
||||
fn(line.characters(), line.length());
|
||||
loop.pump();
|
||||
g_loop.pump();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -153,12 +154,12 @@ int run(Function<void(const char*, size_t)> fn)
|
|||
}
|
||||
auto buffer = file.value()->read_all();
|
||||
fn((const char*)buffer.data(), buffer.size());
|
||||
loop.exec();
|
||||
g_loop.exec();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tls(const char* message, size_t len)
|
||||
static void tls(const char* message, size_t len)
|
||||
{
|
||||
static RefPtr<TLS::TLSv12> tls;
|
||||
static ByteBuffer write {};
|
||||
|
@ -177,17 +178,17 @@ void tls(const char* message, size_t len)
|
|||
}
|
||||
};
|
||||
tls->on_tls_error = [&](auto) {
|
||||
loop.quit(1);
|
||||
g_loop.quit(1);
|
||||
};
|
||||
tls->on_tls_finished = [&]() {
|
||||
loop.quit(0);
|
||||
g_loop.quit(0);
|
||||
};
|
||||
}
|
||||
write.append(message, len);
|
||||
write.append("\r\n", 2);
|
||||
}
|
||||
|
||||
void aes_cbc(const char* message, size_t len)
|
||||
static void aes_cbc(const char* message, size_t len)
|
||||
{
|
||||
auto buffer = ByteBuffer::wrap(const_cast<char*>(message), len);
|
||||
// FIXME: Take iv as an optional parameter
|
||||
|
@ -219,19 +220,19 @@ void aes_cbc(const char* message, size_t len)
|
|||
}
|
||||
}
|
||||
|
||||
void adler32(const char* message, size_t len)
|
||||
static void adler32(const char* message, size_t len)
|
||||
{
|
||||
auto checksum = Crypto::Checksum::Adler32({ (const u8*)message, len });
|
||||
printf("%#10X\n", checksum.digest());
|
||||
}
|
||||
|
||||
void crc32(const char* message, size_t len)
|
||||
static void crc32(const char* message, size_t len)
|
||||
{
|
||||
auto checksum = Crypto::Checksum::CRC32({ (const u8*)message, len });
|
||||
printf("%#10X\n", checksum.digest());
|
||||
}
|
||||
|
||||
void md5(const char* message, size_t len)
|
||||
static void md5(const char* message, size_t len)
|
||||
{
|
||||
auto digest = Crypto::Hash::MD5::hash((const u8*)message, len);
|
||||
if (binary)
|
||||
|
@ -240,7 +241,7 @@ void md5(const char* message, size_t len)
|
|||
print_buffer({ digest.data, Crypto::Hash::MD5::digest_size() }, -1);
|
||||
}
|
||||
|
||||
void hmac_md5(const char* message, size_t len)
|
||||
static void hmac_md5(const char* message, size_t len)
|
||||
{
|
||||
Crypto::Authentication::HMAC<Crypto::Hash::MD5> hmac(secret_key);
|
||||
auto mac = hmac.process((const u8*)message, len);
|
||||
|
@ -250,7 +251,7 @@ void hmac_md5(const char* message, size_t len)
|
|||
print_buffer({ mac.data, hmac.digest_size() }, -1);
|
||||
}
|
||||
|
||||
void sha1(const char* message, size_t len)
|
||||
static void sha1(const char* message, size_t len)
|
||||
{
|
||||
auto digest = Crypto::Hash::SHA1::hash((const u8*)message, len);
|
||||
if (binary)
|
||||
|
@ -259,7 +260,7 @@ void sha1(const char* message, size_t len)
|
|||
print_buffer({ digest.data, Crypto::Hash::SHA1::digest_size() }, -1);
|
||||
}
|
||||
|
||||
void sha256(const char* message, size_t len)
|
||||
static void sha256(const char* message, size_t len)
|
||||
{
|
||||
auto digest = Crypto::Hash::SHA256::hash((const u8*)message, len);
|
||||
if (binary)
|
||||
|
@ -268,7 +269,7 @@ void sha256(const char* message, size_t len)
|
|||
print_buffer({ digest.data, Crypto::Hash::SHA256::digest_size() }, -1);
|
||||
}
|
||||
|
||||
void hmac_sha256(const char* message, size_t len)
|
||||
static void hmac_sha256(const char* message, size_t len)
|
||||
{
|
||||
Crypto::Authentication::HMAC<Crypto::Hash::SHA256> hmac(secret_key);
|
||||
auto mac = hmac.process((const u8*)message, len);
|
||||
|
@ -278,7 +279,7 @@ void hmac_sha256(const char* message, size_t len)
|
|||
print_buffer({ mac.data, hmac.digest_size() }, -1);
|
||||
}
|
||||
|
||||
void sha512(const char* message, size_t len)
|
||||
static void sha512(const char* message, size_t len)
|
||||
{
|
||||
auto digest = Crypto::Hash::SHA512::hash((const u8*)message, len);
|
||||
if (binary)
|
||||
|
@ -287,7 +288,7 @@ void sha512(const char* message, size_t len)
|
|||
print_buffer({ digest.data, Crypto::Hash::SHA512::digest_size() }, -1);
|
||||
}
|
||||
|
||||
void hmac_sha512(const char* message, size_t len)
|
||||
static void hmac_sha512(const char* message, size_t len)
|
||||
{
|
||||
Crypto::Authentication::HMAC<Crypto::Hash::SHA512> hmac(secret_key);
|
||||
auto mac = hmac.process((const u8*)message, len);
|
||||
|
@ -496,7 +497,7 @@ auto main(int argc, char** argv) -> int
|
|||
g_some_test_failed = true; \
|
||||
} while (0)
|
||||
|
||||
ByteBuffer operator""_b(const char* string, size_t length)
|
||||
static ByteBuffer operator""_b(const char* string, size_t length)
|
||||
{
|
||||
dbg() << "Create byte buffer of size " << length;
|
||||
return ByteBuffer::copy(string, length);
|
||||
|
@ -504,62 +505,62 @@ ByteBuffer operator""_b(const char* string, size_t length)
|
|||
|
||||
// tests go after here
|
||||
// please be reasonable with orders kthx
|
||||
void aes_cbc_test_name();
|
||||
void aes_cbc_test_encrypt();
|
||||
void aes_cbc_test_decrypt();
|
||||
void aes_ctr_test_name();
|
||||
void aes_ctr_test_encrypt();
|
||||
void aes_ctr_test_decrypt();
|
||||
static void aes_cbc_test_name();
|
||||
static void aes_cbc_test_encrypt();
|
||||
static void aes_cbc_test_decrypt();
|
||||
static void aes_ctr_test_name();
|
||||
static void aes_ctr_test_encrypt();
|
||||
static void aes_ctr_test_decrypt();
|
||||
|
||||
void md5_test_name();
|
||||
void md5_test_hash();
|
||||
void md5_test_consecutive_updates();
|
||||
static void md5_test_name();
|
||||
static void md5_test_hash();
|
||||
static void md5_test_consecutive_updates();
|
||||
|
||||
void sha1_test_name();
|
||||
void sha1_test_hash();
|
||||
static void sha1_test_name();
|
||||
static void sha1_test_hash();
|
||||
|
||||
void sha256_test_name();
|
||||
void sha256_test_hash();
|
||||
static void sha256_test_name();
|
||||
static void sha256_test_hash();
|
||||
|
||||
void sha512_test_name();
|
||||
void sha512_test_hash();
|
||||
static void sha512_test_name();
|
||||
static void sha512_test_hash();
|
||||
|
||||
void hmac_md5_test_name();
|
||||
void hmac_md5_test_process();
|
||||
static void hmac_md5_test_name();
|
||||
static void hmac_md5_test_process();
|
||||
|
||||
void hmac_sha256_test_name();
|
||||
void hmac_sha256_test_process();
|
||||
static void hmac_sha256_test_name();
|
||||
static void hmac_sha256_test_process();
|
||||
|
||||
void hmac_sha512_test_name();
|
||||
void hmac_sha512_test_process();
|
||||
static void hmac_sha512_test_name();
|
||||
static void hmac_sha512_test_process();
|
||||
|
||||
void rsa_test_encrypt();
|
||||
void rsa_test_der_parse();
|
||||
void rsa_test_encrypt_decrypt();
|
||||
void rsa_emsa_pss_test_create();
|
||||
void bigint_test_number_theory(); // FIXME: we should really move these num theory stuff out
|
||||
static void rsa_test_encrypt();
|
||||
static void rsa_test_der_parse();
|
||||
static void rsa_test_encrypt_decrypt();
|
||||
static void rsa_emsa_pss_test_create();
|
||||
static void bigint_test_number_theory(); // FIXME: we should really move these num theory stuff out
|
||||
|
||||
void tls_test_client_hello();
|
||||
static void tls_test_client_hello();
|
||||
|
||||
void bigint_test_fibo500();
|
||||
void bigint_addition_edgecases();
|
||||
void bigint_subtraction();
|
||||
void bigint_multiplication();
|
||||
void bigint_division();
|
||||
void bigint_base10();
|
||||
void bigint_import_export();
|
||||
void bigint_bitwise();
|
||||
static void bigint_test_fibo500();
|
||||
static void bigint_addition_edgecases();
|
||||
static void bigint_subtraction();
|
||||
static void bigint_multiplication();
|
||||
static void bigint_division();
|
||||
static void bigint_base10();
|
||||
static void bigint_import_export();
|
||||
static void bigint_bitwise();
|
||||
|
||||
void bigint_test_signed_fibo500();
|
||||
void bigint_signed_addition_edgecases();
|
||||
void bigint_signed_subtraction();
|
||||
void bigint_signed_multiplication();
|
||||
void bigint_signed_division();
|
||||
void bigint_signed_base10();
|
||||
void bigint_signed_import_export();
|
||||
void bigint_signed_bitwise();
|
||||
static void bigint_test_signed_fibo500();
|
||||
static void bigint_signed_addition_edgecases();
|
||||
static void bigint_signed_subtraction();
|
||||
static void bigint_signed_multiplication();
|
||||
static void bigint_signed_division();
|
||||
static void bigint_signed_base10();
|
||||
static void bigint_signed_import_export();
|
||||
static void bigint_signed_bitwise();
|
||||
|
||||
int aes_cbc_tests()
|
||||
static int aes_cbc_tests()
|
||||
{
|
||||
aes_cbc_test_name();
|
||||
if (encrypting) {
|
||||
|
@ -571,7 +572,7 @@ int aes_cbc_tests()
|
|||
return g_some_test_failed ? 1 : 0;
|
||||
}
|
||||
|
||||
void aes_cbc_test_name()
|
||||
static void aes_cbc_test_name()
|
||||
{
|
||||
I_TEST((AES CBC class name));
|
||||
Crypto::Cipher::AESCipher::CBCMode cipher("WellHelloFriends"_b, 128, Crypto::Cipher::Intent::Encryption);
|
||||
|
@ -581,7 +582,7 @@ void aes_cbc_test_name()
|
|||
PASS;
|
||||
}
|
||||
|
||||
void aes_cbc_test_encrypt()
|
||||
static void aes_cbc_test_encrypt()
|
||||
{
|
||||
auto test_it = [](auto& cipher, auto& result) {
|
||||
auto in = "This is a test! This is another test!"_b;
|
||||
|
@ -644,7 +645,7 @@ void aes_cbc_test_encrypt()
|
|||
}
|
||||
// TODO: Test non-CMS padding options
|
||||
}
|
||||
void aes_cbc_test_decrypt()
|
||||
static void aes_cbc_test_decrypt()
|
||||
{
|
||||
auto test_it = [](auto& cipher, auto& result, auto result_len) {
|
||||
auto true_value = "This is a test! This is another test!";
|
||||
|
@ -698,7 +699,7 @@ void aes_cbc_test_decrypt()
|
|||
// TODO: Test non-CMS padding options
|
||||
}
|
||||
|
||||
int aes_ctr_tests()
|
||||
static int aes_ctr_tests()
|
||||
{
|
||||
aes_ctr_test_name();
|
||||
if (encrypting) {
|
||||
|
@ -710,7 +711,7 @@ int aes_ctr_tests()
|
|||
return g_some_test_failed ? 1 : 0;
|
||||
}
|
||||
|
||||
void aes_ctr_test_name()
|
||||
static void aes_ctr_test_name()
|
||||
{
|
||||
I_TEST((AES CTR class name));
|
||||
Crypto::Cipher::AESCipher::CTRMode cipher("WellHelloFriends"_b, 128, Crypto::Cipher::Intent::Encryption);
|
||||
|
@ -721,7 +722,7 @@ void aes_ctr_test_name()
|
|||
}
|
||||
|
||||
#define AS_BB(x) (ByteBuffer::wrap((x), sizeof((x)) / sizeof((x)[0])))
|
||||
void aes_ctr_test_encrypt()
|
||||
static void aes_ctr_test_encrypt()
|
||||
{
|
||||
auto test_it = [](auto key, auto ivec, auto in, auto out_expected) {
|
||||
// nonce is already included in ivec.
|
||||
|
@ -916,7 +917,7 @@ void aes_ctr_test_encrypt()
|
|||
}
|
||||
}
|
||||
|
||||
void aes_ctr_test_decrypt()
|
||||
static void aes_ctr_test_decrypt()
|
||||
{
|
||||
auto test_it = [](auto key, auto ivec, auto in, auto out_expected) {
|
||||
// nonce is already included in ivec.
|
||||
|
@ -955,7 +956,7 @@ void aes_ctr_test_decrypt()
|
|||
// If encryption works, then decryption works, too.
|
||||
}
|
||||
|
||||
int md5_tests()
|
||||
static int md5_tests()
|
||||
{
|
||||
md5_test_name();
|
||||
md5_test_hash();
|
||||
|
@ -963,7 +964,7 @@ int md5_tests()
|
|||
return g_some_test_failed ? 1 : 0;
|
||||
}
|
||||
|
||||
void md5_test_name()
|
||||
static void md5_test_name()
|
||||
{
|
||||
I_TEST((MD5 class name));
|
||||
Crypto::Hash::MD5 md5;
|
||||
|
@ -973,7 +974,7 @@ void md5_test_name()
|
|||
PASS;
|
||||
}
|
||||
|
||||
void md5_test_hash()
|
||||
static void md5_test_hash()
|
||||
{
|
||||
{
|
||||
I_TEST((MD5 Hashing | "Well hello friends"));
|
||||
|
@ -1048,7 +1049,7 @@ void md5_test_hash()
|
|||
}
|
||||
}
|
||||
|
||||
void md5_test_consecutive_updates()
|
||||
static void md5_test_consecutive_updates()
|
||||
{
|
||||
{
|
||||
I_TEST((MD5 Hashing | Multiple Updates));
|
||||
|
@ -1088,28 +1089,28 @@ void md5_test_consecutive_updates()
|
|||
}
|
||||
}
|
||||
|
||||
int hmac_md5_tests()
|
||||
static int hmac_md5_tests()
|
||||
{
|
||||
hmac_md5_test_name();
|
||||
hmac_md5_test_process();
|
||||
return g_some_test_failed ? 1 : 0;
|
||||
}
|
||||
|
||||
int hmac_sha256_tests()
|
||||
static int hmac_sha256_tests()
|
||||
{
|
||||
hmac_sha256_test_name();
|
||||
hmac_sha256_test_process();
|
||||
return g_some_test_failed ? 1 : 0;
|
||||
}
|
||||
|
||||
int hmac_sha512_tests()
|
||||
static int hmac_sha512_tests()
|
||||
{
|
||||
hmac_sha512_test_name();
|
||||
hmac_sha512_test_process();
|
||||
return g_some_test_failed ? 1 : 0;
|
||||
}
|
||||
|
||||
void hmac_md5_test_name()
|
||||
static void hmac_md5_test_name()
|
||||
{
|
||||
I_TEST((HMAC - MD5 | Class name));
|
||||
Crypto::Authentication::HMAC<Crypto::Hash::MD5> hmac("Well Hello Friends");
|
||||
|
@ -1119,7 +1120,7 @@ void hmac_md5_test_name()
|
|||
PASS;
|
||||
}
|
||||
|
||||
void hmac_md5_test_process()
|
||||
static void hmac_md5_test_process()
|
||||
{
|
||||
{
|
||||
I_TEST((HMAC - MD5 | Basic));
|
||||
|
@ -1148,14 +1149,14 @@ void hmac_md5_test_process()
|
|||
}
|
||||
}
|
||||
|
||||
int sha1_tests()
|
||||
static int sha1_tests()
|
||||
{
|
||||
sha1_test_name();
|
||||
sha1_test_hash();
|
||||
return g_some_test_failed ? 1 : 0;
|
||||
}
|
||||
|
||||
void sha1_test_name()
|
||||
static void sha1_test_name()
|
||||
{
|
||||
I_TEST((SHA1 class name));
|
||||
Crypto::Hash::SHA1 sha;
|
||||
|
@ -1166,7 +1167,7 @@ void sha1_test_name()
|
|||
PASS;
|
||||
}
|
||||
|
||||
void sha1_test_hash()
|
||||
static void sha1_test_hash()
|
||||
{
|
||||
{
|
||||
I_TEST((SHA256 Hashing | ""));
|
||||
|
@ -1220,14 +1221,14 @@ void sha1_test_hash()
|
|||
}
|
||||
}
|
||||
|
||||
int sha256_tests()
|
||||
static int sha256_tests()
|
||||
{
|
||||
sha256_test_name();
|
||||
sha256_test_hash();
|
||||
return g_some_test_failed ? 1 : 0;
|
||||
}
|
||||
|
||||
void sha256_test_name()
|
||||
static void sha256_test_name()
|
||||
{
|
||||
I_TEST((SHA256 class name));
|
||||
Crypto::Hash::SHA256 sha;
|
||||
|
@ -1238,7 +1239,7 @@ void sha256_test_name()
|
|||
PASS;
|
||||
}
|
||||
|
||||
void sha256_test_hash()
|
||||
static void sha256_test_hash()
|
||||
{
|
||||
{
|
||||
I_TEST((SHA256 Hashing | "Well hello friends"));
|
||||
|
@ -1266,7 +1267,7 @@ void sha256_test_hash()
|
|||
}
|
||||
}
|
||||
|
||||
void hmac_sha256_test_name()
|
||||
static void hmac_sha256_test_name()
|
||||
{
|
||||
I_TEST((HMAC - SHA256 | Class name));
|
||||
Crypto::Authentication::HMAC<Crypto::Hash::SHA256> hmac("Well Hello Friends");
|
||||
|
@ -1276,7 +1277,7 @@ void hmac_sha256_test_name()
|
|||
PASS;
|
||||
}
|
||||
|
||||
void hmac_sha256_test_process()
|
||||
static void hmac_sha256_test_process()
|
||||
{
|
||||
{
|
||||
I_TEST((HMAC - SHA256 | Basic));
|
||||
|
@ -1331,14 +1332,14 @@ void hmac_sha256_test_process()
|
|||
}
|
||||
}
|
||||
|
||||
int sha512_tests()
|
||||
static int sha512_tests()
|
||||
{
|
||||
sha512_test_name();
|
||||
sha512_test_hash();
|
||||
return g_some_test_failed ? 1 : 0;
|
||||
}
|
||||
|
||||
void sha512_test_name()
|
||||
static void sha512_test_name()
|
||||
{
|
||||
I_TEST((SHA512 class name));
|
||||
Crypto::Hash::SHA512 sha;
|
||||
|
@ -1349,7 +1350,7 @@ void sha512_test_name()
|
|||
PASS;
|
||||
}
|
||||
|
||||
void sha512_test_hash()
|
||||
static void sha512_test_hash()
|
||||
{
|
||||
{
|
||||
I_TEST((SHA512 Hashing | "Well hello friends"));
|
||||
|
@ -1377,7 +1378,7 @@ void sha512_test_hash()
|
|||
}
|
||||
}
|
||||
|
||||
void hmac_sha512_test_name()
|
||||
static void hmac_sha512_test_name()
|
||||
{
|
||||
I_TEST((HMAC - SHA512 | Class name));
|
||||
Crypto::Authentication::HMAC<Crypto::Hash::SHA512> hmac("Well Hello Friends");
|
||||
|
@ -1387,7 +1388,7 @@ void hmac_sha512_test_name()
|
|||
PASS;
|
||||
}
|
||||
|
||||
void hmac_sha512_test_process()
|
||||
static void hmac_sha512_test_process()
|
||||
{
|
||||
{
|
||||
I_TEST((HMAC - SHA512 | Basic));
|
||||
|
@ -1416,7 +1417,7 @@ void hmac_sha512_test_process()
|
|||
}
|
||||
}
|
||||
|
||||
int rsa_tests()
|
||||
static int rsa_tests()
|
||||
{
|
||||
rsa_test_encrypt();
|
||||
rsa_test_der_parse();
|
||||
|
@ -1426,7 +1427,7 @@ int rsa_tests()
|
|||
return g_some_test_failed ? 1 : 0;
|
||||
}
|
||||
|
||||
void rsa_test_encrypt()
|
||||
static void rsa_test_encrypt()
|
||||
{
|
||||
{
|
||||
I_TEST((RSA RAW | Encryption));
|
||||
|
@ -1468,7 +1469,7 @@ void rsa_test_encrypt()
|
|||
}
|
||||
}
|
||||
|
||||
void bigint_test_number_theory()
|
||||
static void bigint_test_number_theory()
|
||||
{
|
||||
{
|
||||
I_TEST((Number Theory | Modular Inverse));
|
||||
|
@ -1494,7 +1495,7 @@ void bigint_test_number_theory()
|
|||
}
|
||||
}
|
||||
|
||||
void rsa_emsa_pss_test_create()
|
||||
static void rsa_emsa_pss_test_create()
|
||||
{
|
||||
{
|
||||
// This is a template validity test
|
||||
|
@ -1505,7 +1506,7 @@ void rsa_emsa_pss_test_create()
|
|||
}
|
||||
}
|
||||
|
||||
void rsa_test_der_parse()
|
||||
static void rsa_test_der_parse()
|
||||
{
|
||||
I_TEST((RSA | ASN1 DER / PEM encoded Key import));
|
||||
auto privkey = R"(-----BEGIN RSA PRIVATE KEY-----
|
||||
|
@ -1528,7 +1529,7 @@ nrDlBQpuxz7bwSyQO7UCIHrYMnDohgNbwtA5ZpW3H1cKKQQvueWm6sxW9P5sUrZ3
|
|||
}
|
||||
}
|
||||
|
||||
void rsa_test_encrypt_decrypt()
|
||||
static void rsa_test_encrypt_decrypt()
|
||||
{
|
||||
I_TEST((RSA | Encrypt));
|
||||
dbg() << " creating rsa object";
|
||||
|
@ -1553,13 +1554,13 @@ void rsa_test_encrypt_decrypt()
|
|||
}
|
||||
}
|
||||
|
||||
int tls_tests()
|
||||
static int tls_tests()
|
||||
{
|
||||
tls_test_client_hello();
|
||||
return g_some_test_failed ? 1 : 0;
|
||||
}
|
||||
|
||||
void tls_test_client_hello()
|
||||
static void tls_test_client_hello()
|
||||
{
|
||||
I_TEST((TLS | Connect and Data Transfer));
|
||||
Core::EventLoop loop;
|
||||
|
@ -1608,7 +1609,7 @@ void tls_test_client_hello()
|
|||
loop.exec();
|
||||
}
|
||||
|
||||
int adler32_tests()
|
||||
static int adler32_tests()
|
||||
{
|
||||
auto do_test = [](ReadonlyBytes input, u32 expected_result) {
|
||||
I_TEST((CRC32));
|
||||
|
@ -1631,7 +1632,7 @@ int adler32_tests()
|
|||
return g_some_test_failed ? 1 : 0;
|
||||
}
|
||||
|
||||
int crc32_tests()
|
||||
static int crc32_tests()
|
||||
{
|
||||
auto do_test = [](ReadonlyBytes input, u32 expected_result) {
|
||||
I_TEST((Adler32));
|
||||
|
@ -1652,7 +1653,7 @@ int crc32_tests()
|
|||
return g_some_test_failed ? 1 : 0;
|
||||
}
|
||||
|
||||
int bigint_tests()
|
||||
static int bigint_tests()
|
||||
{
|
||||
bigint_test_fibo500();
|
||||
bigint_addition_edgecases();
|
||||
|
@ -1675,7 +1676,7 @@ int bigint_tests()
|
|||
return g_some_test_failed ? 1 : 0;
|
||||
}
|
||||
|
||||
Crypto::UnsignedBigInteger bigint_fibonacci(size_t n)
|
||||
static Crypto::UnsignedBigInteger bigint_fibonacci(size_t n)
|
||||
{
|
||||
Crypto::UnsignedBigInteger num1(0);
|
||||
Crypto::UnsignedBigInteger num2(1);
|
||||
|
@ -1687,7 +1688,7 @@ Crypto::UnsignedBigInteger bigint_fibonacci(size_t n)
|
|||
return num1;
|
||||
}
|
||||
|
||||
Crypto::SignedBigInteger bigint_signed_fibonacci(size_t n)
|
||||
static Crypto::SignedBigInteger bigint_signed_fibonacci(size_t n)
|
||||
{
|
||||
Crypto::SignedBigInteger num1(0);
|
||||
Crypto::SignedBigInteger num2(1);
|
||||
|
@ -1698,7 +1699,7 @@ Crypto::SignedBigInteger bigint_signed_fibonacci(size_t n)
|
|||
}
|
||||
return num1;
|
||||
}
|
||||
void bigint_test_fibo500()
|
||||
static void bigint_test_fibo500()
|
||||
{
|
||||
{
|
||||
I_TEST((BigInteger | Fibonacci500));
|
||||
|
@ -1712,7 +1713,7 @@ void bigint_test_fibo500()
|
|||
}
|
||||
}
|
||||
|
||||
void bigint_addition_edgecases()
|
||||
static void bigint_addition_edgecases()
|
||||
{
|
||||
{
|
||||
I_TEST((BigInteger | Edge Cases));
|
||||
|
@ -1740,7 +1741,7 @@ void bigint_addition_edgecases()
|
|||
}
|
||||
}
|
||||
|
||||
void bigint_subtraction()
|
||||
static void bigint_subtraction()
|
||||
{
|
||||
{
|
||||
I_TEST((BigInteger | Simple Subtraction 1));
|
||||
|
@ -1807,7 +1808,7 @@ void bigint_subtraction()
|
|||
}
|
||||
}
|
||||
|
||||
void bigint_multiplication()
|
||||
static void bigint_multiplication()
|
||||
{
|
||||
{
|
||||
I_TEST((BigInteger | Simple Multiplication));
|
||||
|
@ -1843,7 +1844,7 @@ void bigint_multiplication()
|
|||
}
|
||||
}
|
||||
}
|
||||
void bigint_division()
|
||||
static void bigint_division()
|
||||
{
|
||||
{
|
||||
I_TEST((BigInteger | Simple Division));
|
||||
|
@ -1885,7 +1886,7 @@ void bigint_division()
|
|||
}
|
||||
}
|
||||
|
||||
void bigint_base10()
|
||||
static void bigint_base10()
|
||||
{
|
||||
{
|
||||
I_TEST((BigInteger | From String));
|
||||
|
@ -1907,7 +1908,7 @@ void bigint_base10()
|
|||
}
|
||||
}
|
||||
|
||||
void bigint_import_export()
|
||||
static void bigint_import_export()
|
||||
{
|
||||
{
|
||||
I_TEST((BigInteger | BigEndian Decode / Encode roundtrip));
|
||||
|
@ -1955,7 +1956,7 @@ void bigint_import_export()
|
|||
}
|
||||
}
|
||||
|
||||
void bigint_bitwise()
|
||||
static void bigint_bitwise()
|
||||
{
|
||||
{
|
||||
I_TEST((BigInteger | Basic bitwise or));
|
||||
|
@ -2021,7 +2022,7 @@ void bigint_bitwise()
|
|||
}
|
||||
}
|
||||
|
||||
void bigint_test_signed_fibo500()
|
||||
static void bigint_test_signed_fibo500()
|
||||
{
|
||||
{
|
||||
I_TEST((Signed BigInteger | Fibonacci500));
|
||||
|
@ -2035,7 +2036,7 @@ void bigint_test_signed_fibo500()
|
|||
}
|
||||
}
|
||||
|
||||
void bigint_signed_addition_edgecases()
|
||||
static void bigint_signed_addition_edgecases()
|
||||
{
|
||||
{
|
||||
I_TEST((Signed BigInteger | Borrow with zero));
|
||||
|
@ -2060,7 +2061,7 @@ void bigint_signed_addition_edgecases()
|
|||
}
|
||||
}
|
||||
|
||||
void bigint_signed_subtraction()
|
||||
static void bigint_signed_subtraction()
|
||||
{
|
||||
{
|
||||
I_TEST((Signed BigInteger | Simple Subtraction 1));
|
||||
|
@ -2120,7 +2121,7 @@ void bigint_signed_subtraction()
|
|||
}
|
||||
}
|
||||
|
||||
void bigint_signed_multiplication()
|
||||
static void bigint_signed_multiplication()
|
||||
{
|
||||
{
|
||||
I_TEST((Signed BigInteger | Simple Multiplication));
|
||||
|
@ -2157,7 +2158,7 @@ void bigint_signed_multiplication()
|
|||
}
|
||||
}
|
||||
}
|
||||
void bigint_signed_division()
|
||||
static void bigint_signed_division()
|
||||
{
|
||||
{
|
||||
I_TEST((Signed BigInteger | Simple Division));
|
||||
|
@ -2201,7 +2202,7 @@ void bigint_signed_division()
|
|||
}
|
||||
}
|
||||
|
||||
void bigint_signed_base10()
|
||||
static void bigint_signed_base10()
|
||||
{
|
||||
{
|
||||
I_TEST((Signed BigInteger | From String));
|
||||
|
@ -2223,7 +2224,7 @@ void bigint_signed_base10()
|
|||
}
|
||||
}
|
||||
|
||||
void bigint_signed_import_export()
|
||||
static void bigint_signed_import_export()
|
||||
{
|
||||
{
|
||||
I_TEST((Signed BigInteger | BigEndian Decode / Encode roundtrip));
|
||||
|
@ -2251,7 +2252,7 @@ void bigint_signed_import_export()
|
|||
}
|
||||
}
|
||||
|
||||
void bigint_signed_bitwise()
|
||||
static void bigint_signed_bitwise()
|
||||
{
|
||||
{
|
||||
I_TEST((Signed BigInteger | Bitwise or handles sign));
|
||||
|
|
|
@ -144,7 +144,7 @@ JS_DEFINE_NATIVE_FUNCTION(TestRunnerGlobalObject::is_strict_mode)
|
|||
return JS::Value(interpreter.in_strict_mode());
|
||||
}
|
||||
|
||||
double get_time_in_ms()
|
||||
static double get_time_in_ms()
|
||||
{
|
||||
struct timeval tv1;
|
||||
struct timezone tz1;
|
||||
|
@ -154,7 +154,7 @@ double get_time_in_ms()
|
|||
}
|
||||
|
||||
template<typename Callback>
|
||||
void iterate_directory_recursively(const String& directory_path, Callback callback)
|
||||
static void iterate_directory_recursively(const String& directory_path, Callback callback)
|
||||
{
|
||||
Core::DirIterator directory_iterator(directory_path, Core::DirIterator::Flags::SkipDots);
|
||||
|
||||
|
@ -168,7 +168,7 @@ void iterate_directory_recursively(const String& directory_path, Callback callba
|
|||
}
|
||||
}
|
||||
|
||||
Vector<String> get_test_paths(const String& test_root)
|
||||
static Vector<String> get_test_paths(const String& test_root)
|
||||
{
|
||||
Vector<String> paths;
|
||||
|
||||
|
@ -201,7 +201,7 @@ void TestRunner::run()
|
|||
print_test_results();
|
||||
}
|
||||
|
||||
Result<NonnullRefPtr<JS::Program>, ParserError> parse_file(const String& file_path)
|
||||
static Result<NonnullRefPtr<JS::Program>, ParserError> parse_file(const String& file_path)
|
||||
{
|
||||
auto file = Core::File::construct(file_path);
|
||||
auto result = file->open(Core::IODevice::ReadOnly);
|
||||
|
@ -225,7 +225,7 @@ Result<NonnullRefPtr<JS::Program>, ParserError> parse_file(const String& file_pa
|
|||
return Result<NonnullRefPtr<JS::Program>, ParserError>(program);
|
||||
}
|
||||
|
||||
Optional<JsonValue> get_test_results(JS::Interpreter& interpreter)
|
||||
static Optional<JsonValue> get_test_results(JS::Interpreter& interpreter)
|
||||
{
|
||||
auto result = interpreter.get_variable("__TestResults__", interpreter.global_object());
|
||||
auto json_string = JS::JSONObject::stringify_impl(interpreter, interpreter.global_object(), result, JS::js_undefined(), JS::js_undefined());
|
||||
|
@ -337,7 +337,7 @@ enum Modifier {
|
|||
CLEAR,
|
||||
};
|
||||
|
||||
void print_modifiers(Vector<Modifier> modifiers)
|
||||
static void print_modifiers(Vector<Modifier> modifiers)
|
||||
{
|
||||
for (auto& modifier : modifiers) {
|
||||
auto code = [&]() -> String {
|
||||
|
|
|
@ -24,11 +24,11 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/URL.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/JsonValue.h>
|
||||
#include <AK/JsonObject.h>
|
||||
#include <AK/JsonValue.h>
|
||||
#include <AK/QuickSort.h>
|
||||
#include <AK/URL.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/File.h>
|
||||
|
@ -42,9 +42,9 @@
|
|||
#include <LibJS/Runtime/Array.h>
|
||||
#include <LibJS/Runtime/JSONObject.h>
|
||||
#include <LibJS/Runtime/MarkedValueList.h>
|
||||
#include <LibWeb/PageView.h>
|
||||
#include <LibWeb/HTML/Parser/HTMLDocumentParser.h>
|
||||
#include <LibWeb/Loader/ResourceLoader.h>
|
||||
#include <LibWeb/PageView.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#define TOP_LEVEL_TEST_NAME "__$$TOP_LEVEL$$__"
|
||||
|
@ -164,12 +164,12 @@ private:
|
|||
RefPtr<JS::Program> m_web_test_common;
|
||||
};
|
||||
|
||||
double get_time_in_ms()
|
||||
static double get_time_in_ms()
|
||||
{
|
||||
struct timeval tv1;
|
||||
struct timezone tz1;
|
||||
auto return_code = gettimeofday(&tv1, &tz1);
|
||||
ASSERT(return_code >= 0);
|
||||
ASSERT(return_code >= 0);
|
||||
return static_cast<double>(tv1.tv_sec) * 1000.0 + static_cast<double>(tv1.tv_usec) / 1000.0;
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ void iterate_directory_recursively(const String& directory_path, Callback callba
|
|||
}
|
||||
}
|
||||
|
||||
Vector<String> get_test_paths(const String& test_root)
|
||||
static Vector<String> get_test_paths(const String& test_root)
|
||||
{
|
||||
Vector<String> paths;
|
||||
|
||||
|
@ -202,7 +202,8 @@ Vector<String> get_test_paths(const String& test_root)
|
|||
return paths;
|
||||
}
|
||||
|
||||
void TestRunner::run() {
|
||||
void TestRunner::run()
|
||||
{
|
||||
size_t progress_counter = 0;
|
||||
auto test_paths = get_test_paths(m_web_test_root);
|
||||
|
||||
|
@ -228,8 +229,7 @@ void TestRunner::run() {
|
|||
[page_to_load](auto error) {
|
||||
printf("Failed to load test page: %s (%s)", page_to_load.to_string().characters(), error.characters());
|
||||
exit(1);
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
for (auto& path : test_paths) {
|
||||
|
@ -247,7 +247,7 @@ void TestRunner::run() {
|
|||
print_test_results();
|
||||
}
|
||||
|
||||
Result<NonnullRefPtr<JS::Program>, ParserError> parse_file(const String& file_path)
|
||||
static Result<NonnullRefPtr<JS::Program>, ParserError> parse_file(const String& file_path)
|
||||
{
|
||||
auto file = Core::File::construct(file_path);
|
||||
auto result = file->open(Core::IODevice::ReadOnly);
|
||||
|
@ -271,7 +271,7 @@ Result<NonnullRefPtr<JS::Program>, ParserError> parse_file(const String& file_pa
|
|||
return Result<NonnullRefPtr<JS::Program>, ParserError>(program);
|
||||
}
|
||||
|
||||
Optional<JsonValue> get_test_results(JS::Interpreter& interpreter)
|
||||
static Optional<JsonValue> get_test_results(JS::Interpreter& interpreter)
|
||||
{
|
||||
auto result = interpreter.get_variable("__TestResults__", interpreter.global_object());
|
||||
auto json_string = JS::JSONObject::stringify_impl(interpreter, interpreter.global_object(), result, JS::js_undefined(), JS::js_undefined());
|
||||
|
@ -333,8 +333,7 @@ JSFileResult TestRunner::run_file_test(const String& test_path)
|
|||
new_interpreter.global_object().define_property(
|
||||
"libweb_tester",
|
||||
new_interpreter.heap().allocate<TestRunnerObject>(new_interpreter.global_object(), new_interpreter.global_object()),
|
||||
JS::Attribute::Enumerable | JS::Attribute::Configurable
|
||||
);
|
||||
JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
new_interpreter.run(new_interpreter.global_object(), *m_js_test_common);
|
||||
new_interpreter.run(new_interpreter.global_object(), *m_web_test_common);
|
||||
new_interpreter.run(new_interpreter.global_object(), *file_program.value());
|
||||
|
@ -416,8 +415,7 @@ JSFileResult TestRunner::run_file_test(const String& test_path)
|
|||
[page_to_load](auto error) {
|
||||
printf("Failed to load test page: %s (%s)", page_to_load.to_string().characters(), error.characters());
|
||||
exit(1);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
return file_result;
|
||||
}
|
||||
|
@ -435,7 +433,7 @@ enum Modifier {
|
|||
CLEAR,
|
||||
};
|
||||
|
||||
void print_modifiers(Vector<Modifier> modifiers)
|
||||
static void print_modifiers(Vector<Modifier> modifiers)
|
||||
{
|
||||
for (auto& modifier : modifiers) {
|
||||
auto code = [&]() -> String {
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
bool g_there_was_an_error = false;
|
||||
|
||||
[[noreturn]] void fatal_error(const char* format, ...)
|
||||
[[noreturn]] static void fatal_error(const char* format, ...)
|
||||
{
|
||||
fputs("\033[31m", stderr);
|
||||
|
||||
|
@ -334,14 +334,14 @@ private:
|
|||
Mode m_mode { Same };
|
||||
};
|
||||
|
||||
OwnPtr<Condition> parse_complex_expression(char* argv[]);
|
||||
static OwnPtr<Condition> parse_complex_expression(char* argv[]);
|
||||
|
||||
static bool should_treat_expression_as_single_string(const StringView& arg_after)
|
||||
{
|
||||
return arg_after.is_null() || arg_after == "-a" || arg_after == "-o";
|
||||
}
|
||||
|
||||
OwnPtr<Condition> parse_simple_expression(char* argv[])
|
||||
static OwnPtr<Condition> parse_simple_expression(char* argv[])
|
||||
{
|
||||
StringView arg = argv[optind];
|
||||
if (arg.is_null()) {
|
||||
|
@ -468,7 +468,7 @@ OwnPtr<Condition> parse_simple_expression(char* argv[])
|
|||
}
|
||||
}
|
||||
|
||||
OwnPtr<Condition> parse_complex_expression(char* argv[])
|
||||
static OwnPtr<Condition> parse_complex_expression(char* argv[])
|
||||
{
|
||||
auto command = parse_simple_expression(argv);
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
void test_read_from_directory()
|
||||
static void test_read_from_directory()
|
||||
{
|
||||
char buffer[BUFSIZ];
|
||||
int fd = open("/", O_DIRECTORY | O_RDONLY);
|
||||
|
@ -63,7 +63,7 @@ void test_read_from_directory()
|
|||
ASSERT(rc == 0);
|
||||
}
|
||||
|
||||
void test_write_to_directory()
|
||||
static void test_write_to_directory()
|
||||
{
|
||||
char str[] = "oh frick";
|
||||
int fd = open("/", O_DIRECTORY | O_RDONLY);
|
||||
|
@ -76,7 +76,7 @@ void test_write_to_directory()
|
|||
ASSERT(rc == 0);
|
||||
}
|
||||
|
||||
void test_read_from_writeonly()
|
||||
static void test_read_from_writeonly()
|
||||
{
|
||||
char buffer[BUFSIZ];
|
||||
int fd = open("/tmp/xxxx123", O_CREAT | O_WRONLY);
|
||||
|
@ -87,7 +87,7 @@ void test_read_from_writeonly()
|
|||
ASSERT(rc == 0);
|
||||
}
|
||||
|
||||
void test_write_to_readonly()
|
||||
static void test_write_to_readonly()
|
||||
{
|
||||
char str[] = "hello";
|
||||
int fd = open("/tmp/abcd123", O_CREAT | O_RDONLY);
|
||||
|
@ -98,7 +98,7 @@ void test_write_to_readonly()
|
|||
ASSERT(rc == 0);
|
||||
}
|
||||
|
||||
void test_read_past_eof()
|
||||
static void test_read_past_eof()
|
||||
{
|
||||
char buffer[BUFSIZ];
|
||||
int fd = open("/home/anon/myfile.txt", O_RDONLY);
|
||||
|
@ -118,7 +118,7 @@ void test_read_past_eof()
|
|||
ASSERT(rc == 0);
|
||||
}
|
||||
|
||||
void test_ftruncate_readonly()
|
||||
static void test_ftruncate_readonly()
|
||||
{
|
||||
int fd = open("/tmp/trunctest", O_RDONLY | O_CREAT, 0666);
|
||||
ASSERT(fd >= 0);
|
||||
|
@ -127,7 +127,7 @@ void test_ftruncate_readonly()
|
|||
close(fd);
|
||||
}
|
||||
|
||||
void test_ftruncate_negative()
|
||||
static void test_ftruncate_negative()
|
||||
{
|
||||
int fd = open("/tmp/trunctest", O_RDWR | O_CREAT, 0666);
|
||||
ASSERT(fd >= 0);
|
||||
|
@ -136,7 +136,7 @@ void test_ftruncate_negative()
|
|||
close(fd);
|
||||
}
|
||||
|
||||
void test_mmap_directory()
|
||||
static void test_mmap_directory()
|
||||
{
|
||||
int fd = open("/tmp", O_RDONLY | O_DIRECTORY);
|
||||
ASSERT(fd >= 0);
|
||||
|
@ -152,7 +152,7 @@ void test_mmap_directory()
|
|||
close(fd);
|
||||
}
|
||||
|
||||
void test_tmpfs_read_past_end()
|
||||
static void test_tmpfs_read_past_end()
|
||||
{
|
||||
int fd = open("/tmp/x", O_RDWR | O_CREAT | O_TRUNC, 0600);
|
||||
ASSERT(fd >= 0);
|
||||
|
@ -171,7 +171,7 @@ void test_tmpfs_read_past_end()
|
|||
close(fd);
|
||||
}
|
||||
|
||||
void test_procfs_read_past_end()
|
||||
static void test_procfs_read_past_end()
|
||||
{
|
||||
int fd = open("/proc/uptime", O_RDONLY);
|
||||
ASSERT(fd >= 0);
|
||||
|
@ -187,7 +187,7 @@ void test_procfs_read_past_end()
|
|||
close(fd);
|
||||
}
|
||||
|
||||
void test_open_create_device()
|
||||
static void test_open_create_device()
|
||||
{
|
||||
int fd = open("/tmp/fakedevice", (O_RDWR | O_CREAT), (S_IFCHR | 0600));
|
||||
ASSERT(fd >= 0);
|
||||
|
@ -205,7 +205,7 @@ void test_open_create_device()
|
|||
close(fd);
|
||||
}
|
||||
|
||||
void test_unlink_symlink()
|
||||
static void test_unlink_symlink()
|
||||
{
|
||||
int rc = symlink("/proc/2/foo", "/tmp/linky");
|
||||
if (rc < 0) {
|
||||
|
@ -223,7 +223,7 @@ void test_unlink_symlink()
|
|||
}
|
||||
}
|
||||
|
||||
void test_eoverflow()
|
||||
static void test_eoverflow()
|
||||
{
|
||||
int fd = open("/tmp/x", O_RDWR);
|
||||
ASSERT(fd >= 0);
|
||||
|
@ -243,7 +243,7 @@ void test_eoverflow()
|
|||
close(fd);
|
||||
}
|
||||
|
||||
void test_rmdir_while_inside_dir()
|
||||
static void test_rmdir_while_inside_dir()
|
||||
{
|
||||
int rc = mkdir("/home/anon/testdir", 0700);
|
||||
ASSERT(rc == 0);
|
||||
|
@ -263,7 +263,7 @@ void test_rmdir_while_inside_dir()
|
|||
ASSERT(rc == 0);
|
||||
}
|
||||
|
||||
void test_writev()
|
||||
static void test_writev()
|
||||
{
|
||||
int pipefds[2];
|
||||
pipe(pipefds);
|
||||
|
@ -294,7 +294,7 @@ void test_writev()
|
|||
close(pipefds[1]);
|
||||
}
|
||||
|
||||
void test_rmdir_root()
|
||||
static void test_rmdir_root()
|
||||
{
|
||||
int rc = rmdir("/");
|
||||
if (rc != -1 || errno != EBUSY) {
|
||||
|
@ -303,7 +303,7 @@ void test_rmdir_root()
|
|||
}
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
int main()
|
||||
{
|
||||
int rc;
|
||||
EXPECT_ERROR_2(ENOTDIR, open, "/dev/zero", (O_DIRECTORY | O_RDONLY));
|
||||
|
|
Loading…
Reference in a new issue