<commit_before>/*
 * Copyright (c) 2018 Intel Corporation.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <ztest.h>
#include <stdio.h>
#include <limits.h>
#include <sys/__assert.h>
#include <fs/fs.h>
#include "test_common.h"

int test_rmdir(const char *dir_path);

int test_mkdir(const char *dir_path, const char *file)
{
	int res;
	struct fs_file_t filep;
	char file_path[PATH_MAX] = { 0 };

	fs_file_t_init(&filep);
	res = sprintf(file_path, "%s/%s", dir_path, file);
	__ASSERT_NO_MSG(res < sizeof(file_path));

	if (check_file_dir_exists(dir_path)) {
		TC_PRINT("[%s] exists, delete it\n", dir_path);
		if (test_rmdir(dir_path)) {
			TC_PRINT("Error deleting dir %s\n", dir_path);
			return TC_FAIL;
		}
	} else {
		TC_PRINT("Creating new dir %s\n", dir_path);
	}
<commit_msg>tests: fs: define PATH_MAX if missing<commit_after>/*
 * Copyright (c) 2018 Intel Corporation.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <ztest.h>
#include <stdio.h>
#include <limits.h>
#include <sys/__assert.h>
#include <fs/fs.h>
#include "test_common.h"

#ifndef PATH_MAX
#define PATH_MAX 4096
#endif

int test_rmdir(const char *dir_path);

int test_mkdir(const char *dir_path, const char *file)
{
	int res;
	struct fs_file_t filep;
	char file_path[PATH_MAX] = { 0 };

	fs_file_t_init(&filep);
	res = sprintf(file_path, "%s/%s", dir_path, file);
	__ASSERT_NO_MSG(res < sizeof(file_path));

	if (check_file_dir_exists(dir_path)) {
		TC_PRINT("[%s] exists, delete it\n", dir_path);
		if (test_rmdir(dir_path)) {
			TC_PRINT("Error deleting dir %s\n", dir_path);
			return TC_FAIL;
		}
	} else {
		TC_PRINT("Creating new dir %s\n", dir_path);
	}

{'fraction_non_alphanumeric': 0.15604128718882818, 'fraction_numerical': 0.01092896174863388, 'mean_word_length': 4.782456140350877, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1452307', 'n_tokens_mistral': 710, 'n_tokens_neox': 667, 'n_words': 149}