test-hostname-pick-word: add a simple test to check word selection
This is useful to check if how fast the code is (painfully slow) and whether worlds indeed are selected with a flat distribution probability (they are). The code is slow because the hashing and because chaseat is exteremely inefficient :(
This commit is contained in:
@@ -369,7 +369,7 @@ static int pick_word_linear_scan(FILE *f, off_t offset, char **ret) {
|
||||
}
|
||||
}
|
||||
|
||||
static int hostname_pick_word(sd_id128_t mid, size_t pos, char **ret) {
|
||||
int hostname_pick_word(sd_id128_t mid, size_t pos, char **ret) {
|
||||
static const sd_id128_t word_key = SD_ID128_MAKE(2d,9f,1c,7a,4b,8e,43,11,9a,6d,5f,02,c8,77,e3,14);
|
||||
_cleanup_fclose_ FILE *f = NULL;
|
||||
struct stat st;
|
||||
|
||||
@@ -22,6 +22,7 @@ int read_etc_hostname(const char *path, bool substitute_wildcards, char **ret);
|
||||
void hostname_update_source_hint(const char *hostname, HostnameSource source);
|
||||
int hostname_setup(bool really);
|
||||
|
||||
int hostname_pick_word(sd_id128_t mid, size_t pos, char **ret);
|
||||
int hostname_substitute_wildcards(const char *name, char **ret);
|
||||
|
||||
char* get_default_hostname(void);
|
||||
|
||||
Reference in New Issue
Block a user