-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ltp/kernel: add compat implementation for compiling ltp kernel cases
Signed-off-by: guoshichao <[email protected]>
- Loading branch information
1 parent
aba32a5
commit b3d4c81
Showing
30 changed files
with
847 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (C) 2024 Xiaomi Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* asm/posix_types.h */ | ||
|
||
#ifndef _ASM_POSIX_TYPES_H | ||
#define _ASM_POSIX_TYPES_H | ||
|
||
/* This is just a placeholder to simplify cross-compiling the LTP Linux Kernel cases */ | ||
|
||
#endif /* _ASM_POSIX_TYPES_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (C) 2024 Xiaomi Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* asm/types.h */ | ||
|
||
#ifndef _ASM_TYPES_H | ||
#define _ASM_TYPES_H | ||
|
||
#include <sys/types.h> | ||
|
||
#endif /* _ASM_TYPES_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/* | ||
* Copyright (C) 2024 Xiaomi Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <nuttx/config.h> | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
#include <string.h> | ||
#include <mntent.h> | ||
|
||
/* the following implementation build when CONFIG_SYSTEM_POPEN option is disabled.*/ | ||
|
||
#ifndef CONFIG_SYSTEM_POPEN | ||
|
||
FILE *popen(const char *command, const char *mode) | ||
{ | ||
return NULL; | ||
} | ||
|
||
int pclose(FILE *stream) | ||
{ | ||
return OK; | ||
} | ||
#endif | ||
|
||
/* the following empty implementation using to compile the LTP Kernel case on nuttx */ | ||
int chroot(const char *path) | ||
{ | ||
return -1; | ||
} | ||
|
||
int setpgid(pid_t pid, pid_t pgid) | ||
{ | ||
return -1; | ||
} | ||
|
||
FILE *setmntent(const char *filep, const char *type) | ||
{ | ||
return NULL; | ||
} | ||
|
||
struct mntent *getmntent(FILE *filep) | ||
{ | ||
return NULL; | ||
} | ||
|
||
struct mntent *getmntent_r(FILE *, struct mntent *, char *, int) | ||
{ | ||
return NULL; | ||
} | ||
|
||
int endmntent(FILE *filep) | ||
{ | ||
return -1; | ||
} | ||
|
||
char *hasmntopt(const struct mntent *mnt, const char *opt) | ||
{ | ||
return NULL; | ||
} | ||
|
||
/* the following are dummy implementation using to compile fsgid related cased on nuttx */ | ||
|
||
int setfsgid(uid_t fsgid) | ||
{ | ||
return -1; | ||
} | ||
|
||
int setfsuid(uid_t fsuid) | ||
{ | ||
return -1; | ||
} | ||
|
||
/* the following syscalls are needed by: | ||
* lib/tst_safe_macros.c | ||
* lib/safe_macros.c | ||
* lib/parse_opts.c | ||
*/ | ||
int mincore(void *addr, size_t length, unsigned char *vec) | ||
{ | ||
return -1; | ||
} | ||
|
||
pid_t setsid(void) | ||
{ | ||
return -1; | ||
} | ||
|
||
int brk(void *addr) | ||
{ | ||
return -1; | ||
} | ||
|
||
#ifndef CONFIG_BUILD_KERNEL | ||
|
||
void *sbrk(intptr_t increment) | ||
{ | ||
return NULL; | ||
} | ||
|
||
#endif | ||
|
||
int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid) | ||
{ | ||
return -1; | ||
} | ||
|
||
int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid) | ||
{ | ||
return -1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (C) 2024 Xiaomi Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* features.h */ | ||
|
||
#ifndef _FEATURES_H | ||
#define _FEATURES_H | ||
|
||
/* This is just a placeholder to simplify cross-compiling the LTP Linux Kernel cases */ | ||
|
||
#endif /* _FEATURES_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (C) 2024 Xiaomi Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* posix_clocks.h */ | ||
|
||
#ifndef _LAPI_POSIX_CLOCKS_H__ | ||
#define _LAPI_POSIX_CLOCKS_H__ | ||
|
||
#include <time.h> | ||
|
||
#define MAX_CLOCKS 16 | ||
|
||
#define CLOCK_MONOTONIC_RAW 5 | ||
|
||
#define CLOCK_REALTIME_COARSE 6 | ||
|
||
#define CLOCK_MONOTONIC_COARSE 7 | ||
|
||
#define CLOCK_REALTIME_ALARM 8 | ||
|
||
#define CLOCK_BOOTTIME_ALARM 9 | ||
|
||
#define CLOCK_TAI 11 | ||
|
||
#endif /* _LAPI_POSIX_CLOCKS_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (C) 2024 Xiaomi Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* libaio.h */ | ||
|
||
#ifndef _LIBAIO_H | ||
#define _LIBAIO_H | ||
|
||
/* This is just a placeholder to simplify cross-compiling the LTP Linux Kernel cases */ | ||
|
||
#endif /* _LIBAIO_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (C) 2024 Xiaomi Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* linux/errno.h */ | ||
|
||
#ifndef _LINUX_ERRNO_H | ||
#define _LINUX_ERRNO_H | ||
|
||
#include <errno.h> | ||
|
||
#endif /* _LINUX_ERRNO_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (C) 2024 Xiaomi Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* linux/fs.h */ | ||
|
||
#ifndef _LINUX_FS_H | ||
#define _LINUX_FS_H | ||
|
||
#include <nuttx/fs/fs.h> | ||
|
||
#endif /* _LINUX_FS_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (C) 2024 Xiaomi Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* linux/futex.h */ | ||
|
||
#ifndef _LINUX_FUTEX_H | ||
#define _LINUX_FUTEX_H | ||
|
||
#define FUTEX_WAIT 1 | ||
#define FUTEX_WAKE 2 | ||
|
||
#endif /* _LINUX_FUTEX_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (C) 2024 Xiaomi Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* linux/if_tun.h */ | ||
|
||
#ifndef _LINUX_IF_TUN_H | ||
#define _LINUX_IF_TUN_H | ||
|
||
/* This is just a placeholder to simplify cross-compiling the LTP Linux Kernel cases */ | ||
|
||
#endif /* _LINUX_IF_TUN_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (C) 2024 Xiaomi Corporation | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* linux/kernel.h */ | ||
|
||
#ifndef _LINUX_KERNEL_H | ||
#define _LINUX_KERNEL_H | ||
|
||
#include <sys/sysmacros.h> | ||
|
||
#endif /* _LINUX_KERNEL_H */ |
Oops, something went wrong.