mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Add a hello world docker image test for rust runtime.
PiperOrigin-RevId: 603161919
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "hello-world"
|
||||
version = "0.1.0"
|
||||
|
||||
[[bin]]
|
||||
name = "hello-world"
|
||||
path = "helloworld.rs"
|
||||
@@ -0,0 +1,12 @@
|
||||
FROM rust:1.75.0
|
||||
# Set the working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the application files into the image
|
||||
COPY Cargo.toml helloworld.rs ./
|
||||
|
||||
# Build the application in release mode
|
||||
RUN cargo build --release
|
||||
|
||||
# Set the command to run the binary
|
||||
CMD ["./target/release/hello-world"]
|
||||
@@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, World!");
|
||||
}
|
||||
@@ -64,6 +64,25 @@ func TestHelloWorld(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRust(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
d := dockerutil.MakeContainer(ctx, t)
|
||||
defer d.CleanUp(ctx)
|
||||
|
||||
// Run the basic container.
|
||||
out, err := d.Run(ctx, dockerutil.RunOpts{
|
||||
Image: "basic/rust",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("docker run failed: %v", err)
|
||||
}
|
||||
|
||||
// Check the output.
|
||||
if !strings.Contains(out, "Hello, World!") {
|
||||
t.Fatalf("Container didn't say Hello, World!: got %s", out)
|
||||
}
|
||||
}
|
||||
|
||||
func runHTTPRequest(ip string, port int) error {
|
||||
url := fmt.Sprintf("http://%s:%d/not-found", ip, port)
|
||||
resp, err := http.Get(url)
|
||||
|
||||
Reference in New Issue
Block a user