summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/console.h40
-rw-r--r--include/dm/test.h9
-rw-r--r--include/fs.h1
-rw-r--r--include/squashfs.h25
-rw-r--r--include/test/suites.h1
-rw-r--r--include/test/test.h11
-rw-r--r--include/test/ut.h59
-rw-r--r--include/u-boot/zlib.h32
8 files changed, 168 insertions, 10 deletions
diff --git a/include/console.h b/include/console.h
index 4c6b8f2614..432f892b6c 100644
--- a/include/console.h
+++ b/include/console.h
@@ -8,6 +8,7 @@
#define __CONSOLE_H
#include <stdbool.h>
+#include <linux/errno.h>
extern char console_buffer[];
@@ -21,11 +22,14 @@ void clear_ctrlc(void); /* clear the Control-C condition */
int disable_ctrlc(int); /* 1 to disable, 0 to enable Control-C detect */
int confirm_yesno(void); /* 1 if input is "y", "Y", "yes" or "YES" */
+#ifdef CONFIG_CONSOLE_RECORD
/**
* console_record_init() - set up the console recording buffers
*
* This should be called as soon as malloc() is available so that the maximum
* amount of console output can be recorded.
+ *
+ * @return 0 if OK, -ENOMEM if out of memory
*/
int console_record_init(void);
@@ -40,8 +44,10 @@ void console_record_reset(void);
* console_record_reset_enable() - reset and enable the console buffers
*
* This should be called to enable the console buffer.
+ *
+ * @return 0 (always)
*/
-void console_record_reset_enable(void);
+int console_record_reset_enable(void);
/**
* console_record_readline() - Read a line from the console output
@@ -61,6 +67,38 @@ int console_record_readline(char *str, int maxlen);
* @return available bytes (0 if empty)
*/
int console_record_avail(void);
+#else
+static inline int console_record_init(void)
+{
+ /* Always succeed, since it is not enabled */
+
+ return 0;
+}
+
+static inline void console_record_reset(void)
+{
+ /* Nothing to do here */
+}
+
+static inline int console_record_reset_enable(void)
+{
+ /* Cannot enable it as it is not supported */
+ return -ENOSYS;
+}
+
+static inline int console_record_readline(char *str, int maxlen)
+{
+ /* Nothing to read */
+ return 0;
+}
+
+static inline int console_record_avail(void)
+{
+ /* There is never anything available */
+ return 0;
+}
+
+#endif /* !CONFIG_CONSOLE_RECORD */
/**
* console_announce_r() - print a U-Boot console on non-serial consoles
diff --git a/include/dm/test.h b/include/dm/test.h
index 2c92d41278..b2adce730a 100644
--- a/include/dm/test.h
+++ b/include/dm/test.h
@@ -144,15 +144,6 @@ struct dm_test_state {
struct udevice *removed;
};
-/* Test flags for each test */
-enum {
- DM_TESTF_SCAN_PDATA = 1 << 0, /* test needs platform data */
- DM_TESTF_PROBE_TEST = 1 << 1, /* probe test uclass */
- DM_TESTF_SCAN_FDT = 1 << 2, /* scan device tree */
- DM_TESTF_FLAT_TREE = 1 << 3, /* test needs flat DT */
- DM_TESTF_LIVE_TREE = 1 << 4, /* needs live device tree */
-};
-
/* Declare a new driver model test */
#define DM_TEST(_name, _flags) UNIT_TEST(_name, _flags, dm_test)
diff --git a/include/fs.h b/include/fs.h
index b08b1f40c5..0794b50d10 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -15,6 +15,7 @@ struct cmd_tbl;
#define FS_TYPE_SANDBOX 3
#define FS_TYPE_UBIFS 4
#define FS_TYPE_BTRFS 5
+#define FS_TYPE_SQUASHFS 6
struct blk_desc;
diff --git a/include/squashfs.h b/include/squashfs.h
new file mode 100644
index 0000000000..819cf8c2da
--- /dev/null
+++ b/include/squashfs.h
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2020 Bootlin
+ *
+ * Author: Joao Marcos Costa <joaomarcos.costa@bootlin.com>
+ *
+ * squashfs.h: SquashFS filesystem implementation.
+ */
+
+#ifndef _SQFS_H_
+#define _SQFS_H_
+
+struct disk_partition;
+
+int sqfs_opendir(const char *filename, struct fs_dir_stream **dirsp);
+int sqfs_readdir(struct fs_dir_stream *dirs, struct fs_dirent **dentp);
+int sqfs_probe(struct blk_desc *fs_dev_desc,
+ struct disk_partition *fs_partition);
+int sqfs_read(const char *filename, void *buf, loff_t offset,
+ loff_t len, loff_t *actread);
+int sqfs_size(const char *filename, loff_t *size);
+void sqfs_close(void);
+void sqfs_closedir(struct fs_dir_stream *dirs);
+
+#endif /* SQFS_H */
diff --git a/include/test/suites.h b/include/test/suites.h
index f120b3a82a..ab7b3bd9ca 100644
--- a/include/test/suites.h
+++ b/include/test/suites.h
@@ -34,6 +34,7 @@ int do_ut_dm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_lib(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_log(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]);
+int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_optee(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[]);
diff --git a/include/test/test.h b/include/test/test.h
index 029288de88..67c7d69d48 100644
--- a/include/test/test.h
+++ b/include/test/test.h
@@ -7,6 +7,7 @@
#define __TEST_TEST_H
#include <malloc.h>
+#include <linux/bitops.h>
/*
* struct unit_test_state - Entire state of test system
@@ -27,6 +28,16 @@ struct unit_test_state {
char actual_str[256];
};
+/* Test flags for each test */
+enum {
+ UT_TESTF_SCAN_PDATA = BIT(0), /* test needs platform data */
+ UT_TESTF_PROBE_TEST = BIT(1), /* probe test uclass */
+ UT_TESTF_SCAN_FDT = BIT(2), /* scan device tree */
+ UT_TESTF_FLAT_TREE = BIT(3), /* test needs flat DT */
+ UT_TESTF_LIVE_TREE = BIT(4), /* needs live device tree */
+ UT_TESTF_CONSOLE_REC = BIT(5), /* needs console recording */
+};
+
/**
* struct unit_test - Information about a unit test
*
diff --git a/include/test/ut.h b/include/test/ut.h
index 6ab2f8830d..3295cd4e54 100644
--- a/include/test/ut.h
+++ b/include/test/ut.h
@@ -58,6 +58,31 @@ int ut_check_console_line(struct unit_test_state *uts, const char *fmt, ...)
__attribute__ ((format (__printf__, 2, 3)));
/**
+ * ut_check_console_linen() - Check part of the next console line
+ *
+ * This creates a string and then checks it against the next line of console
+ * output obtained with console_record_readline(). Only the length of the
+ * string is checked
+ *
+ * After the function returns, uts->expect_str holds the expected string and
+ * uts->actual_str holds the actual string read from the console.
+ *
+ * @uts: Test state
+ * @fmt: printf() format string for the error, followed by args
+ * @return 0 if OK, other value on error
+ */
+int ut_check_console_linen(struct unit_test_state *uts, const char *fmt, ...)
+ __attribute__ ((format (__printf__, 2, 3)));
+
+/**
+ * ut_check_skipline() - Check that the next console line exists and skip it
+ *
+ * @uts: Test state
+ * @return 0 if OK, other value on error
+ */
+int ut_check_skipline(struct unit_test_state *uts);
+
+/**
* ut_check_console_end() - Check there is no more console output
*
* After the function returns, uts->actual_str holds the actual string read
@@ -152,6 +177,23 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
} \
}
+/*
+ * Assert that two string expressions are equal, up to length of the
+ * first
+ */
+#define ut_asserteq_strn(expr1, expr2) { \
+ const char *_val1 = (expr1), *_val2 = (expr2); \
+ int _len = strlen(_val1); \
+ \
+ if (memcmp(_val1, _val2, _len)) { \
+ ut_failf(uts, __FILE__, __LINE__, __func__, \
+ #expr1 " = " #expr2, \
+ "Expected \"%.*s\", got \"%.*s\"", \
+ _len, _val1, _len, _val2); \
+ return CMD_RET_FAILURE; \
+ } \
+}
+
/* Assert that two memory areas are equal */
#define ut_asserteq_mem(expr1, expr2, len) { \
const u8 *_val1 = (u8 *)(expr1), *_val2 = (u8 *)(expr2); \
@@ -231,6 +273,23 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes);
return CMD_RET_FAILURE; \
} \
+/* Assert that the next console output line matches up to the length */
+#define ut_assert_nextlinen(fmt, args...) \
+ if (ut_check_console_linen(uts, fmt, ##args)) { \
+ ut_failf(uts, __FILE__, __LINE__, __func__, \
+ "console", "\nExpected '%s',\n got '%s'", \
+ uts->expect_str, uts->actual_str); \
+ return CMD_RET_FAILURE; \
+ } \
+
+/* Assert that there is a 'next' console output line, and skip it */
+#define ut_assert_skipline() \
+ if (ut_check_skipline(uts)) { \
+ ut_failf(uts, __FILE__, __LINE__, __func__, \
+ "console", "\nExpected a line, got end"); \
+ return CMD_RET_FAILURE; \
+ } \
+
/* Assert that there is no more console output */
#define ut_assert_console_end() \
if (ut_check_console_end(uts)) { \
diff --git a/include/u-boot/zlib.h b/include/u-boot/zlib.h
index e23ceb50ca..a33cc8780d 100644
--- a/include/u-boot/zlib.h
+++ b/include/u-boot/zlib.h
@@ -110,6 +110,12 @@ extern "C" {
# define voidp z_voidp
#endif
+#if defined(ZLIB_CONST) && !defined(z_const)
+# define z_const const
+#else
+# define z_const
+#endif
+
#if defined(__MSDOS__) && !defined(MSDOS)
# define MSDOS
#endif
@@ -710,6 +716,32 @@ ZEXTERN uInt ZEXPORT crc32 OF((uInt crc, const Bytef *buf, uInt len));
if (crc != original_crc) error();
*/
+ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong sourceLen));
+/*
+ Decompresses the source buffer into the destination buffer. sourceLen is
+ the byte length of the source buffer. Upon entry, destLen is the total size
+ of the destination buffer, which must be large enough to hold the entire
+ uncompressed data. (The size of the uncompressed data must have been saved
+ previously by the compressor and transmitted to the decompressor by some
+ mechanism outside the scope of this compression library.) Upon exit, destLen
+ is the actual size of the uncompressed data.
+
+ uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
+ enough memory, Z_BUF_ERROR if there was not enough room in the output
+ buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In
+ the case where there is not enough room, uncompress() will fill the output
+ buffer with the uncompressed data up to that point.
+*/
+
+ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen,
+ const Bytef *source, uLong *sourceLen));
+/*
+ Same as uncompress, except that sourceLen is a pointer, where the
+ length of the source is *sourceLen. On return, *sourceLen is the number of
+ source bytes consumed.
+*/
+
ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
const char *version, int stream_size));
#define inflateInit(strm) \