mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 22:02:27 +00:00
Improve synchronization
- Fix bugs in kDos2Errno definition - malloc() should now be thread safe - Fix bug in rollup.com header generator - Fix open(O_APPEND) on the New Technology - Fix select() on the New Technology and test it - Work towards refactoring i/o for thread safety - Socket reads and writes on NT now poll for signals - Work towards i/o completion ports on the New Technology - Make read() and write() intermittently check for signals - Blinkenlights keyboard i/o so much better on NT w/ poll() - You can now poll() files and sockets at the same time on NT - Fix bug in appendr() that manifests with dlmalloc footers off
This commit is contained in:
parent
233144b19d
commit
933411ba99
266 changed files with 8761 additions and 4344 deletions
|
@ -16,17 +16,37 @@
|
|||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/sock/select.h"
|
||||
#include "libc/sock/sock.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/time/time.h"
|
||||
|
||||
TEST(select, allZero) {
|
||||
// todo: figure out how to test block until signal w/ select
|
||||
// EXPECT_SYS(0, 0, select(0, 0, 0, 0, 0));
|
||||
// TEST(select, allZero) {
|
||||
// // todo: figure out how to test block until signal w/ select
|
||||
// EXPECT_SYS(0, 0, select(0, 0, 0, 0, 0));
|
||||
// }
|
||||
|
||||
TEST(select, pipe_hasInputFromSameProcess) {
|
||||
fd_set rfds;
|
||||
char buf[2];
|
||||
int pipefds[2];
|
||||
struct timeval tv = {.tv_usec = 100 * 1000};
|
||||
EXPECT_SYS(0, 0, pipe(pipefds));
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(pipefds[0], &rfds);
|
||||
EXPECT_SYS(0, 2, write(pipefds[1], "hi", 2));
|
||||
EXPECT_SYS(0, 1, select(pipefds[0] + 1, &rfds, 0, 0, &tv));
|
||||
EXPECT_TRUE(FD_ISSET(pipefds[0], &rfds));
|
||||
EXPECT_SYS(0, 2, read(pipefds[0], buf, 2));
|
||||
EXPECT_SYS(0, 0, select(pipefds[0] + 1, &rfds, 0, 0, &tv));
|
||||
EXPECT_TRUE(!FD_ISSET(pipefds[0], &rfds));
|
||||
EXPECT_SYS(0, 0, close(pipefds[0]));
|
||||
EXPECT_SYS(0, 0, close(pipefds[1]));
|
||||
}
|
||||
|
||||
#if 0 // flaky
|
||||
TEST(select, testSleep) {
|
||||
int64_t e;
|
||||
long double n;
|
||||
|
@ -40,3 +60,4 @@ TEST(select, testSleep) {
|
|||
EXPECT_EQ(0, t.tv_usec);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue