mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-22 17:55:57 +01:00
30 lines
617 B
JavaScript
Executable File
30 lines
617 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
const assert = require('assert')
|
|
const http = require('http')
|
|
|
|
const express = require('express')
|
|
const app = express()
|
|
const port = 3000
|
|
|
|
app.get('/error', async (req, res) => {
|
|
throw 'my error'
|
|
})
|
|
|
|
const server = app.listen(port, () => {
|
|
// Test it.
|
|
function test(path, method, status, body) {
|
|
const options = {
|
|
hostname: 'localhost',
|
|
port: server.address().port,
|
|
path: path,
|
|
method: method,
|
|
}
|
|
http.request(options, res => {
|
|
console.error(res.statusCode);
|
|
assert(res.statusCode === status);
|
|
}).end()
|
|
}
|
|
test('/error', 'GET', 500)
|
|
})
|